Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hide/Show form fields

 
Pradeep Chandrasekharan Nair
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is there any way to show/hide fields using JSF rather than javascript. Actually my scenario is that I have to show some fields if I select a particular value from <selectOneMenu>

Thanks in Advance
Regards,
Pradeep
 
Gabriel Claramunt
Ranch Hand
Posts: 375
Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the rendered attribute of the JSF components.
I had a similar situation, and I used it successfully.
The main selection used immediate="true" (to avoid validations), and the action in the backing bean was used to set a boolean flag (something like "modeA"), the other JSF components had rendered=#{backingBean.modeA} or rendered=#{!backingBean.modeA} if they should appear in mode A or not.
Probably you can do it also with rendered=#{backingBean.selectionValue==XX} and avoid the use of a flag
 
Pradeep Chandrasekharan Nair
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gabriel. Its working.

Pradeep
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic