Problem with required fields in accordion tab with one form

UI Components for JSF
Post Reply
SaberRider
Posts: 6
Joined: 07 Jul 2011, 10:40

27 Jul 2011, 17:36

Hello,
I have a problem with my accordionPanel with two tabs and required fields in both tabs. The accordionPanel is in one form and when I submit the form both validations fail.

Code: Select all

<h:form>
<p:accordionPanel autoHeight="false" activeIndex="-1" dynamic="true" cache="false">
  <p:tab title="Tab 2" id="t1">
    <p:inputText id="reqTest1" required="true"/>
  </p:tab>
  <p:tab title="Tab 2" id="t2">
    <p:inputText id="reqTest1" required="true"/>
  </p:tab>
</p:accordionPanel>
</h:form>
After opening a tab the content is lodad and not unloaded on closing. So both tabs are validated and I get an error because only the expanded tab is filled.
Now I want the validation only on the one tab that is expanded and not on both. I can't use two forms because I have some content around the accordion to submit too.

Has anyone an idea for this or an alternative component to use?
I need a dynamic content with header and only one at a time expanded and validated.
PrimeFaces 2.2.1 | Majorra 2.0.6 | Spring WebFlow 2.3 | Tomcat 7

ermalaliraj
Posts: 3
Joined: 09 Nov 2012, 20:46

09 Nov 2012, 20:50

I have the same problem and I don't want to use different form for each tab.
Can you please share the solution in case you found how to do that?

Thanks in advance for any input.
Ermal

roguexz
Posts: 8
Joined: 22 Oct 2012, 18:41

09 Nov 2012, 21:37

ermalaliraj wrote:I have the same problem and I don't want to use different form for each tab.
Can you please share the solution in case you found how to do that?

Thanks in advance for any input.
Ermal
Do you have a single submit button or two? In either case, the way to go would be to specify the components of the page that need to be processed. You can specify the id of the currently-open-tab as part of the process attribute.

HTH,
Rogue

ermalaliraj
Posts: 3
Joined: 09 Nov 2012, 20:46

10 Nov 2012, 00:39

I have a single button and the structure is as follow:

Code: Select all

<h:form>
<p:accordionPanel id="purchaseAccordian">
	<p:tab title="Cash" id="cashTab"> 
		<p:inputText required="true"/> 
	</p:tab>

	<p:tab title="Bank">    
		<p:inputText required="true"/> 
	</p:tab>

	<p:commandButton value="Add"  
		update="listTabel" 
		actionListener="#{customerController.addPurchase}"> 					
	</p:commandButton> 
<p:accordionPanel>	
</form>
From what I understood from your comment is that I should add the parameter process="@this, openedTabId" to the button.

There is a way to get at runtime the id of the opened tab?

I tried an example hardcoding tabname as process="@this,cashTab" but seems not to work correctly.

Thank you for your help.
Ermal

ermalaliraj
Posts: 3
Joined: 09 Nov 2012, 20:46

10 Nov 2012, 01:16

you mentioned "You can specify the id of the currently-open-tab as part of the process attribute."

can you write a simple example please?
thank you again.
Ermal

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 48 guests