-1

I have a form in which first component is a dropdown.The below components like text-box,text-area,radio-button,check-box,etc must be displayed based on what is selected in the dropdown.?

How to implement this in JSF using primefaces? Also what are the alternate ways I have to achieve this ?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Why you want to use primefaces here? You can achieve it directly without using primefaces. – Gaurav Jeswani Apr 28 '16 at 04:38
  • Your question is to broad for StackOverflow. It also looks like you did not read any serious tutorial about modern jsf webdevelopment. If you did, you'd know about the concept of ajax and you'd have found many examples. Including one in the PrimeFaces showcase about ajax... So this quesition is too broad and (imo) shows to little effort in trying things – Kukeltje Apr 28 '16 at 06:34
  • Duplicate: http://stackoverflow.com/questions/10385278/conditional-rendering-in-jsf – Kukeltje Apr 28 '16 at 06:36

1 Answers1

0

Consider you form like below:

    <f:form> 
        <h:panelGroup layout="block">   
        <h:selectOneMenu id="dropdownValue" label="#{resourceBundleLabels.countryLabel}"    value="#{bean.value}">  
            <f:selectItems value="#{XYZ)}"  var="variable" itemLabel="#{variable.decode}"   itemValue="#{variable.code}"/>  
            <f:ajax event="valueChange" execute="@this" render="updateSection"> 
            </f:ajax> 
        </h:selectOneMenu> 
        </h:panelGroup> 
        <h:panelGroup layout="block" id="updateSection"> 
        <h:inputText id="textValue" value="#{bean.textValue}" rendered="#{bean.value eq 'A'}"> <h:inputText> 
        </h:panelGroup> 
    </f:form>

In this form suppose there is a dropdown with id="dropdownValue". If 'A' is selected in that dropdwon then only we have to display the inputText having id="textValue". So by above example you can implement same in your code.

Gaurav Jeswani
  • 4,410
  • 6
  • 26
  • 47
  • Hi, many of these very basic issues already have a Q and A in Stackoverflow. Marking it as a duplicate is the better thing to do in cases like this: http://stackoverflow.com/questions/10385278/conditional-rendering-in-jsf – Kukeltje Apr 28 '16 at 06:38