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
Chamil MadusankaChamil Madusanka 

Getting error in visual page - need help

I'm getting the error "Return type of an Apex action method must be a PageReference. Found: core.apexpages.el.ApexELResolver$VisualforceArrayList"

 

What is the issue?

 

 

/**Visual page **/

 

<apex:page standardController="Applicant__c" recordSetVar="applicant" extensions="view">
  <apex:form >
      <apex:pageBlock >
          <apex:outputLabel value="Status :" for="status"/>
          <apex:inputField id="status" value="{!Applicant__c.Status__c}">
          <apex:actionSupport event="onchange" action="{!getApplicantByStatus}" reRender="view"/>
              <apex:param name="para" value="{!Applicant__c.Status__c}" assignTo="{!para}"/>
             
            
          </apex:inputField>
      
      </apex:pageBlock>
       <apex:pageBlock >
           <apex:panelgroup id="view">
              <apex:pageBlockTable id="viewApplicant" value="{!applicantByStatus}" var="app">
                  <apex:column headerValue="Applicant ID" value="{!app.Name}">
                              
                  </apex:column>
                  <!-- <apex:column headerValue="Applicant Name" value="{!app.Name__c}">
              
                  </apex:column>-->
              </apex:pageBlockTable>
           </apex:panelgroup>
      </apex:pageBlock> 
      
  </apex:form>
</apex:page>

 /**Controller code**/

 

public class view {

    public Applicant__c applicant;
    public List<Applicant__c> applicantByStatus {get;set;}
    private ApexPages.StandardSetController controller;
   
    public List<String> applicantNameByStatus{get;set;}
    
    public String para{
        get;
        
        set{
           para=value;
        
        }
    }
    
    public List<String> displayFields {
        get; private set;
    }
    
    public view(ApexPages.StandardSetController controller) {
        this.applicant=(Applicant__c)controller.getRecord();
        //this.controller = controller;
    }
    
    public List<Applicant__C> getApplicantByStatus(){
        
         applicantByStatus=new List<Applicant__c>();
         applicantByStatus=[SELECT Name,Name__c,Status__c,Interview_Date_Time__c FROM Applicant__c WHERE Status__c =:para];
         
         if(applicantByStatus==null){
             System.Debug('APPLICANT STATUS IS NULL');
         }
         for(Applicant__c app:applicantByStatus){
             String name=app.Name__c;
             System.Debug('CHECK :: '+app.Name__c);
             applicantNameByStatus.add('app.Name__c');
         }
         
         //applicantNameByStatus.add('Chamil');
          //applicantNameByStatus.add('madusanka');
          // applicantNameByStatus.add('applicant1');
         
         return applicantByStatus;
    } 
}

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
BaLab2aBaLab2a

Apex action method must be PageReference method.

 

**Controller**

 

public Pagereference process()

{

getApplicantByStatus();
return null;

}

 

 

**Visualforce**

 

<apex:actionSupport event="onchange" action="{!process}" reRender="view"/>

 

 

Check whether it is helpful..

 

Thanks,

BaLa

 

All Answers

AhmedPotAhmedPot

Hi,

 

Your action method in actionsupport is returning list of applicant instead of pagereference. You can change return type of your action method to either void or pagereference. Anyway you are rerendering your panel grid, so updated value will be displayed inside your panel. May be this should help you.

 

Thanks,

Ahmed

BaLab2aBaLab2a

Apex action method must be PageReference method.

 

**Controller**

 

public Pagereference process()

{

getApplicantByStatus();
return null;

}

 

 

**Visualforce**

 

<apex:actionSupport event="onchange" action="{!process}" reRender="view"/>

 

 

Check whether it is helpful..

 

Thanks,

BaLa

 

This was selected as the best answer