my dog learned polymorphism*
The moose likes JSF and the fly likes Dynamically visibility control in JSF using selectOneMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Dynamically visibility control in JSF using selectOneMenu" Watch "Dynamically visibility control in JSF using selectOneMenu" New topic
Author

Dynamically visibility control in JSF using selectOneMenu

Debajyoti Kundu
Greenhorn

Joined: Sep 14, 2011
Posts: 23
Hi,
I'm trying to implement a functionality which will control the visibility of three outputText. I'm using a selectOneMenu, which has three options. Each option will enable visibility of one outputText, and rest will be invisible.

I used the following code

<h:selectOneMenu id="search" styleClass="select-box" value="#{empMB.showHide}" required="true" requiredMessage="Please Select an Option" >
<f:selectItem itemLabel="-----Select----"/>
<f:selectItem itemLabel="By Name" itemValue="1"/>
<f:selectItem itemLabel="By Id" itemValue="2"/>
<f:selectItem itemLabel="By Phone No" itemValue="3"/>
</h:selectOneMenu>

<h:outputText rendered="#{empMB.showHide ==1 }" value="Hello 1"></h:outputText>
<h:outputText rendered="#{empMB.showHide ==2 }" value="Hello 2"></h:outputText>
<h:outputText rendered="#{empMB.showHide ==3 }" value="Hello 3"></h:outputText>


Initially all outputText s is invisible as rendered value is false, but when I select different options, their respective outputText s are not visible.

Can anyone help me with this?

Thanks & Regards,
Debajyoti Kundu
Debajyoti Kundu
Greenhorn

Joined: Sep 14, 2011
Posts: 23
Found the error.. It's working now
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dynamically visibility control in JSF using selectOneMenu
 
Similar Threads
SelectOneMenu Validation
To open JSF web page in new window for selected options
Setting default value to h: selectOneMenu on button click
javax.xml.rpc.soap.SOAPFaultException: System.Web.Services.Protocols.SoapException:
Richface/Primefaces Elements are not rendered