DynaForm and TabView

Community Driven Extensions Project
Post Reply
rmdd
Posts: 1
Joined: 27 Oct 2015, 23:30

05 Nov 2015, 14:28

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

maille42
Posts: 2
Joined: 14 Feb 2017, 11:28

14 Feb 2017, 12:55

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

Code: Select all

 <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.

maille42
Posts: 2
Joined: 14 Feb 2017, 11:28

14 Feb 2017, 13:00

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

Code: Select all

 <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.

Babas007
Posts: 197
Joined: 24 May 2011, 09:42

18 Feb 2017, 11:03

Please provide a sample so I can see your problem

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests