File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Hide/Show form fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Hide/Show form fields" Watch "Hide/Show form fields" New topic

Hide/Show form fields

Pradeep Chandrasekharan Nair
Ranch Hand

Joined: Apr 01, 2004
Posts: 48

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
Gabriel Claramunt
Ranch Hand

Joined: May 26, 2007
Posts: 375

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

Software Surgeon
Pradeep Chandrasekharan Nair
Ranch Hand

Joined: Apr 01, 2004
Posts: 48
Thanks Gabriel. Its working.

I agree. Here's the link:
subject: Hide/Show form fields
It's not a secret anymore!