0

I am having two picklist field in VF Page.Based on the 2nd picklist value i need to make the 1st picklist field mandatory, which works fine.,but the issue is once i selected the value in 2nd picklist then the value in 1 st picklist changed, it is not displaying the value I already selected.How can solve this issues. Please let me know what am I doing wrong here

Image1

Image2

Piklist 1:
<apex:pageBlockSectionItem >   
    <apex:outputlabel value="{!$ObjectType.Case.fields.Is_booking_with_Primary_Freight__c.label}" for="Request"/>    
    <apex:outputPanel id="panel1">   
   <apex:inputField value="{!cases.Is_booking_with_Primary_Freight__c}"  required="{!if(reason == 'Rebook - Bring Booking Forward'||reason == 'Rebook - No Show'||reason == 'Rebook - Transport Company Issue'||reason == 'Rebook - Order was Rejected on initial delivery'||reason == 'Rebook - Vendor Issue'||reason == 'Rebook - BIG W Issue'||reason == 'Consolidate Orders',true,false) }"/>   
   </apex:outputPanel>   
    </apex:pageBlockSectionItem>

Picklist 2:
<apex:pageBlockSectionItem >     
  <apex:outputLabel value="Request Reason" />
  <apex:actionRegion >
  <apex:outputPanel styleClass="requiredInput" layout="block" id="pwPanel" > 
   <apex:outputPanel styleClass="requiredBlock"/>
 <apex:selectList id="Request_Reason" size="1" value="{!reason}"  label="Request Reason"  required="true" style="width: 155px; " >
     <apex:selectOptions value="{!reasons}" />     
     <apex:actionSupport event="onchange" reRender="panel1"  />     
  </apex:selectList>
 </apex:outputPanel>
  </apex:actionRegion>
   </apex:pageBlockSectionItem>

1 Answer 1

1
  1. When you change the value of picklist2, you are executing <apex:actionSupport event="onchange" reRender="panel1" />
  2. This transmits to the server the changed values on the VF page within the enclosing actionRegion.
  3. The enclosing actionRegion doesn't include the picklist1 inputField {!cases.Is_booking_with_Primary_Freight__c} so upon rerender, the value will be from the current server value - not what was in the box on the browser (never sent to server)

Solution: Make the scope of the actionRegion include both picklist1 and picklist2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .