+ Start a Discussion
Amit SAmit S 

Rendered not working

I am using the below sectin in VF page to render selectively based on Value of Opportunity Stage

            <apex:pageBlockSection id="Stage_Details" title="Stage Details" >
                
                <apex:repeat id="Opportunity_Stage_Fields" value="{!OpportunityStageFields}" var="f">
                     <apex:pageBlockSectionItem >
                         <apex:outputLabel id="fs_contract_type_label" value="{!$ObjectType.Opportunity.Fields[f].label}"/>
                         <apex:inputField id="fs_contract_type" value="{!sOpportunity[f]}">
                             <apex:actionSupport event="onchange" immediate="true" rerender="Stage_Details"  rendered="true"/>    
                         </apex:inputField>
                     </apex:pageBlockSectionItem>                                                                              
                 </apex:repeat><br/>
                 
                 <apex:repeat id="Reason_Comments" value="{!OpportunityStageReasonFields}" var="f">
                     
                     <apex:pageBlockSectionItem rendered="{!if(sOpportunity.stagename == 'Closed On Hold','true','false')}">
            <apex:outputLabel id="fs_Reason_label" value="{!$ObjectType.Opportunity.Fields[f].label}"/>
                         <apex:inputField id="fs_Reason" value="{!sOpportunity[f]}" rendered="{!if(sOpportunity.StageName == 'Closed On Hold','true','false')}"/>                        
                     </apex:pageBlockSectionItem>                                                                             
                 </apex:repeat>
                 
            </apex:pageBlockSection>


Below is the sections added in Controller


    public List<Schema.FieldSetMember> getOpportunityStageFields() {
            return SObjectType.Opportunity.FieldSets.Opportunity_Stage.getFields();
    }


    public List<Schema.FieldSetMember> getOpportunityStageReasonFields() {
            return SObjectType.Opportunity.FieldSets.Opportunity_Stage_Reason_Closed.getFields();
    }


Additionally have created two field sets 
1) Opportunity_Stage (field Opportunity Stage) 
2) Opportunity_Stage_Reason_Closed (Reason Closed & Reason Closed COmments)


Still once I change the status of the Field Opportunity Stage, if does not return with the Reason Closed & Reason Closed COmments fields.
Best Answer chosen by Amit S
Mudasir WaniMudasir Wani
Amit - 

Remove the 
immediate="true"
As done in below line
  <apex:actionSupport event="onchange"  rerender="Stage_Details"  rendered="true"/> 

and then try.
Let me know the progress ..

 

All Answers

Mudasir WaniMudasir Wani
Amit - 

Remove the 
immediate="true"
As done in below line
  <apex:actionSupport event="onchange"  rerender="Stage_Details"  rendered="true"/> 

and then try.
Let me know the progress ..

 
This was selected as the best answer
Amit SAmit S
Helped. Below code worked

 <apex:pageBlockSection id="Stage_Details" title="Stage Details" rendered="true">
                
                <apex:repeat id="Opportunity_Stage_Fields" value="{!OpportunityStageFields}" var="f">
                     <apex:pageBlockSectionItem >
                         <apex:outputLabel id="fs_stage_label" value="{!$ObjectType.Opportunity.Fields[f].label}"/>
                         <apex:inputField id="fs_stage" value="{!sOpportunity[f]}">
                             <apex:actionSupport event="onchange" rerender="Stage_Details"  rendered="true"/>
                         </apex:inputField>
                     </apex:pageBlockSectionItem>                                                                              
                 </apex:repeat><br/>
                 
                 <apex:repeat id="Reason_Comments" value="{!OpportunityStageReasonFields}" var="f" rendered="true">                     
                     <apex:pageBlockSectionItem rendered="{!if(sOpportunity.stagename == 'Closed On Hold','true','false')}">
                         <apex:outputLabel id="fs_Reason_label" value="{!$ObjectType.Opportunity.Fields[f].label}"/>
                         <apex:inputField id="fs_Reason" value="{!sOpportunity[f]}" rendered="{!if(sOpportunity.StageName == 'Closed On Hold','true','false')}"/>    
                     </apex:pageBlockSectionItem>                                                                             
                 </apex:repeat>
                 
</apex:pageBlockSection>
Mudasir WaniMudasir Wani

Please select the reply as best answer which solves your problem.
This will help others with same issue.Also our efforts in the community will be visible