function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ritesh__Ritesh__ 

reRender is not working as expected in visualforce

i am sure i am doing a very small mistake.i created a visualforce page with code

<apex:page standardController="RuleCriteria__c" extensions="AW_RuleCriteriaController3">
<apex:form >
<apex:pageBlock title="Rule Criteria Detail">
         <apex:pageBlockButtons >
             <apex:commandButton value="Save" />
             <apex:commandButton value="Save and New" />
             <apex:commandButton value="Cancel" />
         </apex:pageBlockButtons>
         <apex:pageBlockSection title="Information">
         </apex:pageBlockSection>
         <apex:pageBlockSection columns="1">
         <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Related Object"></apex:outputLabel>
                         <apex:selectList value="{!objType}" size="1" onchange="fieldNamesList(this.options[this.selectedIndex].value);">
                             <apex:selectOptions value="{!objOptions}"/>
                         </apex:selectList>
                 </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                       <apex:outputLabel value="Field Name"></apex:outputLabel>
                         <apex:outputPanel id="fieldPanel"> 
                             <apex:outputPanel layout="block" styleClass="requiredInput">
                                <apex:outputPanel layout="block" styleClass="requiredBlock"/>
                             <apex:selectList value="{!fieldName}" size="1" onchange="setFieldApiName(this.options[this.selectedIndex].value)">
                                 <apex:selectOptions value="{!fieldOption}"/>
                             </apex:selectList>
                             </apex:outputPanel>
                          </apex:outputPanel> 

                     </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Field Type"></apex:outputLabel>
                         <apex:outputPanel id="fieldTypeApiPanel"> 
                             <apex:outputText value="{! fieldType}"/>
                          </apex:outputPanel>
                 </apex:pageBlockSectionItem>  
                 <apex:pageBlockSectionItem >
                 <apex:outputLabel value="Operator" />
                 <apex:outputPanel id="operatorPanel"> 
                 <apex:selectList value="{!newRuleCriteria.Matching_Type__c}"  size="1" >
<apex:selectOptions value="{! Operator}" ></apex:selectOptions> 
</apex:selectList>
</apex:outputPanel>  
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{! isPicklist}" id="picklist">
<apex:outputLabel value="Matching Value"> </apex:outputLabel>
<apex:selectList value="{!newRuleCriteria.Matching_Value__c}" size="1"  >
                            <apex:selectOptions value="{! PickListValues}"/>                            
                        </apex:selectList>


</apex:pageBlockSectionItem >
<apex:pageBlockSectionItem rendered="{! isInput}" id='input1'>
<apex:outputLabel value="Matching Value"></apex:outputLabel>
<apex:inputFIeld value="{! newRuleCriteria.Matching_Value__c}"  />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{! isCheckBox}" id='check'>
<apex:outputLabel value="Matching Value"></apex:outputLabel>
                        <apex:inputCheckBox value="{! newRuleCriteria.Matching_Value__c}"/>

</apex:pageBlockSectionItem>
                 </apex:pageBlockSection>
         </apex:pageBlock>
         <apex:actionRegion >
       <apex:actionFunction name="fieldNamesList" action="{!getFieldNames}" reRender="fieldPanel">
        <apex:param assignTo="{!parentName}" value="" name="parentName"/>
        </apex:actionFunction>
     </apex:actionRegion>
         <apex:actionRegion >  
       <apex:actionFunction name="setFieldApiName" action="{!setFieldApiName}" reRender="picklist,input1,check,operatorPanel,fieldTypeApiPanel">
        <apex:param  value="" name="fieldName"/>
       </apex:actionFunction>   
     </apex:actionRegion>

         </apex:form>
</apex:page>

 

 

and the extension code function is this

public pageReference setFieldApiName(){
fieldName = Apexpages.currentPage().getParameters().get('fieldName');
if(fieldName != null && fieldName.length() >0){
fieldType = Schema.getGlobalDescribe().get(objType).getDescribe().fields.getMap().get(fieldName).getDescribe().getType().name();
if(Schema.DisplayType.PickList == Schema.getGlobalDescribe().get(objType).getDescribe().fields.getMap().get(fieldName).getDescribe().getType()) {isPicklist=true; isCheckBox = false;
isInput =false; isMinMax = false;}
if(Schema.DisplayType.Boolean == Schema.getGlobalDescribe().get(objType).getDescribe().fields.getMap().get(fieldName).getDescribe().getType())
{isPicklist=false; isCheckBox=true; isInput= false; isMinMax= false; }
}else {fieldType=''; isMinMax=isCheckBox=isPickList=false; isInput=true; }
System.debug('pick list is '+isPickList); return null; }

 

 in this page in one select list i am showing Label of objects when user select label then in second list i show fields corresponding to that label but when i select a field actionFunction selectFieldApiName called.and in debug log it is showing pick list is true. but there is not picklist is rendering i think after selecting a picklist field ispickList getting true and then this pageblocksection item should render but it is not rendering can any one please tell where i am wrong.please help!!

bob_buzzardbob_buzzard

The problem here is that you are rerendering something that isn't on the page when first rendered, which won't work.

 

I've explained this much better at:

 

http://bobbuzzard.blogspot.co.uk/2011/02/visualforce-re-rendering-woes.html