Board index JavaServer Faces Extensions DynaForm and TabView

DynaForm and TabView

Community Driven Extensions Project

Post 05 Nov 2015, 14:28

Posts: 1
Hi,

I want to switch from a static form to a dynamic form.
So DynaForm seems to be perfect for that.

My problem is that the static form splits its inputs across multiple tabs (TabView)
Is it possible to do that with the dynamic solution ?

thanks in advance,

Rem
primefaces 5.3 + extensions 4.0

Post 14 Feb 2017, 12:55

Posts: 2
I am interesting in doing the same thing. My form is split in different tabs showing as an accordion. I am creating several DynaFormModel objects, one for each tab, and i assign each dynamic form field to a row in the relevant models.

I can then display my accordion like this

 <p:accordionPanel multiple="true" var="formPanel" value="#{productForm.formPanels}">
       
        <p:tab title="#{formPanel}" id="#{formPanel}">       
          <pe:dynaForm id="dynaform" value="#{myForm.getPanelFormModel(formPanel)}"" var="data" >
                <pe:dynaFormControl type="input" for="txt" >
                  <p:inputText  id="txt" value="#{data.value}" required="#{data.required}"  />
                  <p:message id="txtErrorMessage" for="txt" />                 
                </pe:dynaFormControl>
         </pe:dynaForm>
       </p:tab>
 </p:accordionPanel>


This works to a point, each field is rendered in the right tab. But i am seeing issues when i want to use primefaces validation on required fields (e.g. p:message ) either inline as per the example above, or the global p:messages tag.

If i add an ajax event such as 'keyup' in my input text definition , with an update attribute set to the message id, i see the inline error message when blanking the field.

My requirement is validation on submit however. With the solution described above, I see the messages on submit if only have 1 tab to render, hence 1 DynaformModel. If i have more than one model, i do not see any messages.

My current thinking is that something is getting confused with multiple <pe:dynaform id="dynaform"> tags, maybe something to do with the id ?

If anybody can advise on how to solve this, I would be grateful.

Post 14 Feb 2017, 13:00

Posts: 2
I am interesting in doing the same thing. My form is split in different tabs showing as an accordion. I am creating several DynaFormModel objects, one for each tab, and i assign each dynamic form field to a row in the relevant models.

I can then display my accordion like this

 <p:accordionPanel multiple="true" var="formPanel" value="#{productForm.formPanels}">
       
        <p:tab title="#{formPanel}" id="#{formPanel}">       
          <pe:dynaForm id="dynaform" value="#{myForm.getPanelFormModel(formPanel)}"" var="data" >
                <pe:dynaFormControl type="input" for="txt" >
                  <p:inputText  id="txt" value="#{data.value}" required="#{data.required}"  />
                  <p:message id="txtErrorMessage" for="txt" />                 
                </pe:dynaFormControl>
         </pe:dynaForm>
       </p:tab>
 </p:accordionPanel>


This works to a point, each field is rendered in the right tab. But i am seeing issues when i want to use primefaces validation on required fields (e.g. p:message ) either inline as per the example above, or the global p:messages tag.

If i add an ajax event such as 'keyup' in my input text definition , with an update attribute set to the message id, i see the inline error message when blanking the field.

My requirement is validation on submit however. With the solution described above, I see the messages on submit if only have 1 tab to render, hence 1 DynaformModel. If i have more than one model, i do not see any messages.

My current thinking is that something is getting confused with multiple <pe:dynaform id="dynaform"> tags, maybe something to do with the id ?

If anybody can advise on how to solve this, I would be grateful.

thank you.

Post 18 Feb 2017, 11:03

Posts: 150
Please provide a sample so I can see your problem


Return to Extensions