Recover dynamic form data in Java PrimeFaces Extension

Community Driven Extensions Project
Post Reply
ciciSami
Posts: 1
Joined: 19 Jan 2020, 11:24

20 Jan 2020, 11:06

my job consists in recovering from a web service a form already filled; modify it with the transmit, the problem that the loop that I made gets the model before the modification I want to know how to recover the form after the modification

Code: Select all

List<ModeleForm> modeles = new ArrayList<ModeleForm>();
for (DynaFormControl dynaFormControl : model.getControls()) {
    System.out.println("recup");
    modeles.add((ModeleForm) dynaFormControl.getData());
}
my page .xhtml which displays the dynamic form

Code: Select all

  <h:panelGroup id="dynaFormGroup"> 

                    <pe:dynaForm id="dynaForm" value="#{tachesController.createForm()}" var="data" 
                                 autoSubmit="true" widgetVar="dynaForm"  >


                        <ui:include  src="colsAddM2.xhtml"/>

                    </pe:dynaForm>
                </h:panelGroup>

Code: Select all

 String url = "http://localhost:8080/activiti-rest/service/form/form-data?taskId=" + idTask + "";
        Representation respons = getClientResource(url).get(MediaType.APPLICATION_JSON);
        JSONObject object = new JSONObject(respons.getText());

        if (object != null) {

            JSONArray formProperties = object.getJSONArray("formProperties");
            DynaFormLabel labels[] = new DynaFormLabel[0];
            DynaFormControl labels2[] = new DynaFormControl[0];

            labels = new DynaFormLabel[formProperties.length()];
            labels2 = new DynaFormControl[formProperties.length()];
            for (int i = 0; i < (formProperties.length()); i++) {
                DynaFormRow row = model.createRegularRow();
                boolean required = Boolean.valueOf(formProperties.getJSONObject(i).getString("required"));
                labels[i] = row.addLabel(formProperties.getJSONObject(i).getString("name"));
                labels2[i] = row.addControl(new ModeleForm(formProperties.getJSONObject(i).getString("name"), formProperties.getJSONObject(i).getString("id"), formProperties.getJSONObject(i).getString("value"), required), getType(formProperties.getJSONObject(i).getString("type")));
                labels[i].setForControl(labels2[i]);}

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

21 Jan 2020, 15:46

@Rapster this is a dynaform issue and I don't use the DynaForm. Can you look?
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests