Reputation: 65
I have 3 drop downs in my jsf page.
It is present in same order in my page.
If I select a value for arrival zone or departure zone and then I select value for voucher zone, the values in 1 and 2 are changed to default values.
Here is my code.
<h:column rendered="#{(fplusRulesHandler.fplusRulesBean.searchBased eq 'DEP ZONE/ARR AIRPORT') or (fplusRulesHandler.fplusRulesBean.searchBased eq 'DEP ZONE/ARR ZONE')}">
<h:outputText styleClass="head-table" value="Departing Zone"></h:outputText>
<h:outputText styleClass="mandatory" value="*" />
</h:column>
<h:column rendered="#{(fplusRulesHandler.fplusRulesBean.searchBased eq 'DEP ZONE/ARR AIRPORT') or (fplusRulesHandler.fplusRulesBean.searchBased eq 'DEP ZONE/ARR ZONE')}">
<h:selectOneMenu value="#{fplusRulesHandler.fplusRulesBean.fpuFlightRules.bpmAppFltIdentity.depZone}">
<f:selectItems value="#{fplusRulesHandler.fplusRulesBean.arrDepZoneList}"></f:selectItems>
</h:selectOneMenu>
</h:column>
<h:column rendered="#{(fplusRulesHandler.fplusRulesBean.searchBased eq 'ARR ZONE/DEP AIRPORT') or (fplusRulesHandler.fplusRulesBean.searchBased eq 'DEP ZONE/ARR ZONE')}">
<h:outputText styleClass="head-table" value="Arrival Zone"></h:outputText>
<h:outputText styleClass="mandatory" value="*" />
</h:column>
<h:column rendered="#{(fplusRulesHandler.fplusRulesBean.searchBased eq 'ARR ZONE/DEP AIRPORT') or (fplusRulesHandler.fplusRulesBean.searchBased eq 'DEP ZONE/ARR ZONE')}">
<h:selectOneMenu value="#{fplusRulesHandler.fplusRulesBean.fpuFlightRules.bpmAppFltIdentity.arrZone}">
<f:selectItems value="#{fplusRulesHandler.fplusRulesBean.arrDepZoneList}"></f:selectItems>
</h:selectOneMenu>
</h:column>
<h:column>
<h:outputLabel styleClass="head-table" value="Voucher Type"></h:outputLabel>
</h:column>
<h:column>
<h:selectOneMenu value="#{fplusRulesHandler.fplusRulesBean.fpuFlightRules.voucherType}">
<f:selectItem itemLabel="LONG HAUL UPGRADE" itemValue="LONG HUAL UPGRADE" />
<f:selectItem itemLabel="EUROPE UPGRADE" itemValue="EUROPE UPGRADE" />
<f:ajax event="change" render="fplusAdd"></f:ajax>
</h:selectOneMenu>
</h:column>
<h:column rendered="#{fplusRulesHandler.fplusRulesBean.fpuFlightRules.voucherType == 'EUROPE UPGRADE'}">
<h:outputLabel styleClass="head-table" value="#{message['FplusRules.AddRules.Label.RedemptionPointDiscount']}"></h:outputLabel>
</h:column>
<h:column rendered="#{fplusRulesHandler.fplusRulesBean.fpuFlightRules.voucherType == 'EUROPE UPGRADE'}">
<h:inputText id="redemptionDiscount" value="#{fplusRulesHandler.fplusRulesBean.fpuFlightRules.redemptionPointsDisc}" validatorMessage="#{errorMessage['redemptionPointDiscountPositive']}"
converterMessage="#{errorMessage['redemptionPointDiscountPositive']}">
<f:convertNumber integerOnly="true"></f:convertNumber>
<f:validateLongRange minimum="0" />
</h:inputText>
<h:message for="redemptionDiscount" errorStyle="padding-left:10px;color :red" />
</h:column>
Upvotes: 0
Views: 132
Reputation: 173
As Nurzhan pointed out as you have not attached any <f:ajax>
tags to the first 2 <h:selectOneMenu>
tags no ajax event is getting fired when the user changes his selection in those menues. That means the setters in your model don't get called.
But on the third <h:selectOneMenu>
you attached an <f:ajax>
tag with a render attribute that references the id of a tag that contains all the menues (as i can presume). Therebye in the render response phase the getters of all components inside 'fplusAdd' are called and the menues are being set back to their inital vales.
To fix that problem either add ajax tags to the first menues as well (so that the model gets updated with each userselection or simply reference them in the the ajax tag in the execute attribute as well, like:
<h:selectOneMenu value="#{fplusRulesHandler.fplusRulesBean.fpuFlightRules.voucherType}">
<f:selectItem itemLabel="LONG HAUL UPGRADE" itemValue="LONG HUAL UPGRADE" />
<f:selectItem itemLabel="EUROPE UPGRADE" itemValue="EUROPE UPGRADE" />
<f:ajax event="change" execute="fplusAdd" render="fplusAdd"></f:ajax>
</h:selectOneMenu>
Therebye the first two menues will also get processed (as well as anything else which is inside 'fplusAdd'), which means that the setters of the model are called. If you don't explicitly add an execute attribute the default value is @this, which means only the component itself is getting processed (the corresponding setters are called)
Upvotes: 1