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
logontokartiklogontokartik 

Setter is called after action method is invoked when using actionSupport in Visualforce

Hi,

 

I have a situation here where the setter method is getting called after the action method is called in Visualforce when using actionsupport tag.

 

Here is the snippet of my VF code

 

 

<apex:column width="20%" >
                    <apex:facet name="header" >Field</apex:facet>
                      <apex:selectList value="{!mf.savedsearchfield.Label__c}" size="1" id="fieldslist" style="width:250px;border:{!savedfieldErr};">
                             <apex:selectOptions value="{!items}" id="fieldsOptions" ></apex:selectOptions>                                                    
                        <apex:actionSupport event="onchange" action="{!getchkLookup}" rerender="addfieldsBlock"> 
                        	<apex:param name="fieldLabel" value="{!mf.savedsearchfield.Label__c}" assignTo="{!fieldLabel}" />                                                                                     
                        </apex:actionSupport>                           
                      </apex:selectList>                                  
                                                 
                    <apex:outputPanel rendered="{!LEN(mf.errMessageFld)!=0}">                      
                     <div class="errorMsg"><strong>Error:</strong>&nbsp;{!mf.errMessageFld}</div>
                     </apex:outputPanel>
                  </apex:column> 
                 
                 <apex:column width="12%" >                
                    <apex:facet name="header">Operator</apex:facet>
                    <apex:inputField value="{!mf.savedsearchfield.Operator__c}" style="width:100px;"/>
                    <apex:outputPanel rendered="{!LEN(mf.errMessageOp)!=0}">                      
                     <div class="errorMsg"><strong>Error:</strong>&nbsp;{!mf.errMessageOp}</div>
                     </apex:outputPanel>
                 </apex:column>                 
                 
                 <apex:column width="20%" id="valuecolumn">                                     
                    <apex:facet name="header">Value</apex:facet>
                    <apex:inputField value="{!mf.savedsearchfield.DefaultValue__c}"  rendered="{!LEN(mf.errMessageVal)==0}"/>                    
                    <apex:commandButton value=".." action="{!getisLookup}" rendered="{!mf.isLookup}" id="lookupButton">
   <apex:actionSupport event="onclick" rerender="popup" immediate="true">                            
        <apex:param name="fieldLabel" value="{!mf.savedsearchfield.Label__c}" assignTo="{!fieldLabel}" /> 
  </apex:actionSupport>  

 Here are my action and setter methods - 

 

 

public String fieldLabel {
  	get {
  		return fieldLabel;  		
  	}
  	set {  		
  		fieldLabel = value;
  		system.debug('fieldLabel' + fieldLabel);
  	}
  }
  
  public PageReference getisLookup(){
  	
  	String fieldLabelName = Apexpages.currentPage().getParameters().get('fieldLabel');
  	system.debug('fieldLabelName ' + fieldLabelName);
  	if(fieldLabel != '' && fieldLabel != null){
  		system.debug('inside if islookup');
  		getchkLookup();
  		for(Integer i=0;i<wsavedsearchfields.size();i++){
  		if(fieldLabel == wsavedsearchfields[i].savedsearchfield.Label__c ){
  			if (wsavedsearchfields[i].isLookup)
  				isLookupfld = true;
  		}
  	 }
  	}
  	else {
  		system.debug('inside else islookup');  		
  		getchkLookup();
  		Integer lsize = wsavedsearchfields.size();
  		isLookupfld = false;
  		if(wsavedsearchfields[lsize-1].isLookup == true){
  				isLookupfld = true;
  		 }    	
  	}
   	return null;
  }

 

 

I am not sure if I need to do something else on actionSupport to invoke setter first and then action method. i am stuck on this for 2 days now, I am trying to get a parameter passed back to controller so that I can perform my login in controller.

 

Any help is appreciated. Thanks.

 

Shashikant SharmaShashikant Sharma

Please change 

immediate="true" to  immediate="false" , by this you will stop property bindings in setter.