Note that there are some explanatory texts on larger screens.

plurals
  1. POMake multiple dependent / cascading selectOneMenu dropdown lists in JSF
    primarykey
    data
    text
    <p>I am trying to make 4 dependent menus.</p> <p>When the user chooses an item from the first menu, the second menu will show dependent data and when the user chooses item from the second one , the third one will show dependent data and so on.</p> <p>The user will see items on the first menu only and the other ones will be blank. If he chooses an item on the first menu the second one will show data but the third and the fourth will remain blank, and so on. The user must eventually choose entries from all the 4 menus.</p> <pre><code>&lt;h:selectOneMenu id="first" value="#{nodes.selectState"}&gt; &lt;f:selectItems value="#{nodes.stateList}"/&gt; &lt;f:ajax render="second"&gt; &lt;/h:selectOneMenu&gt; &lt;h:selectOneMenu id="second" value="#{nodes.selectCity"}&gt; &lt;f:selectItems value="#{nodes.cityList}"/&gt; &lt;f:ajax render="third"&gt; &lt;/h:selectOneMenu&gt; &lt;h:selectOneMenu id="third" value="#{nodes.selectRegion"}&gt; &lt;f:selectItems value="#{nodes.regionList}"/&gt; &lt;f:ajax render="fourth"&gt; &lt;/h:selectOneMenu&gt; &lt;h:selectOneMenu id="fourth" value="#{nodes.selectStation"}&gt; &lt;f:selectItems value="#{nodes.stationList}"/&gt; &lt;/h:selectOneMenu&gt; </code></pre> <p>nodes Java Class</p> <pre><code>private String selectState; //+setters, getters private String selectCity; //+setters, getters private String selectRegion; //+setters, getters private String selectStation; //+setters, getters private List&lt;SelectItem&gt; stateList; //+setters, getters private List&lt;SelectItem&gt; cityList; //+setters, getters private List&lt;SelectItem&gt; regionList; //+setters, getters private List&lt;SelectItem&gt; stationList; //+setters, getters public getStateList(){ stateList= new ArrayList&lt;SelectItem&gt;(); stateList.add(new SelectItem("A")); } public getCityList(){ CityList= new ArrayList&lt;SelectItem&gt;(); if(selectState.equals("A")){ CityList.add(new SelectItem("B")); } } public getRegionList(){ RegionList= new ArrayList&lt;SelectItem&gt;(); if(selectCity.equals("B")){ RegionList.add(new SelectItem("C")); } } public getStationList(){ StationList= new ArrayList&lt;SelectItem&gt;(); if(selectRegion.equals("C")){ StationList.add(new SelectItem("D")); } } </code></pre> <p>it's only working at the first 2 menus the other 2 menus get null values</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload