0

I have four dependent dropdown boxes A, Layout, Farm and D. Each of which is showing list of data depending on the previous dropdown box selected value. If I select a value in dropdown box Layout all the data related to Layout is fetched from database and displayed in Farm dropdown. The default value for all the dropdown boxes is select-one. If I select a option in one dropdown box automatically the next dropdown box is showing select-one as default.

But in the third dropdown box Farm, I have an option All. If I select 'All' in Farm, go back to Layout dropdown and select a different option, the dropdown box Farm is not changing to select-one as default value. It is showing All as default value but I want select-one. Can anybody help me how to display select-one as default value instead of 'All'.

<p:column>
    <p:selectOneMenu id="laylist" value="#{imageBean.selectedlayoutid}">
        <f:selectItem itemValue="0" itemLabel="select-one" noSelectionOption="true"/>
        <f:selectItems value="#{imageBean.layoutids}" var="lay" itemLabel="#{lay.layoutname}" itemValue="#{lay.layoutid}"/>
        <p:ajax update="farlist"/>
    </p:selectOneMenu>
</p:column>
<p:column>
    <p:selectOneMenu id="farlist" value="#{imageBean.selectedfarmid}">
        <f:selectItem itemLabel="select-one" itemValue="" noSelectionOption="true" />
        <f:selectItem itemValue="allfarm" itemLabel="All" />
        <f:selectItems value="#{imageBean.farms}" var="far" itemLabel="#{far.farmname}" itemValue="#{far.farmid}"/>
        <p:ajax update="mplist" />
    </p:selectOneMenu>
</p:column>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
msk
  • 43
  • 1
  • 8
  • @BalusC, I am populating the lists in the getter method of . What logic do I need to implement in listener? because Farm dropdown is not showing the select-one default value only when I select All option in it and go back to Layout dropdown to choose different option. And if user tries to select All option (which is already selected), the value is not returned to the managed bean class. – msk Mar 11 '16 at 09:51
  • See duplicate. In the future never do business logic in getter methods of backing beans. Let those methods plain return the already-prepared properties. You'll easier be forced to do things the right way, or to find out the right ways. – BalusC Mar 11 '16 at 09:51

0 Answers0