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
Prasanthi BPrasanthi B 

Command button action is not getting invoked in visualforce page



My requirement is to have one search button in a VF page. And display the search results in a table with a checkbox for each record. Some records need to be selected and only those records have to be updated with some input value given on the same VF page.


The problem here is, first search button is working fine and displaying the results. But the update command button action is not getting invoked in the controller class.


Please find the code below.


This is very critical requorement which needs to be delivered.



It would be great if anyone could look into it and suggest.




<apex:page StandardController="User" id="thePage" Extensions="UserData">
  <apex:form >
  <apex:pageBlock title="SelectUsers" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
   Select Region of the user:
   <apex:inputField id="startMode" value="{!User.Region__c}" />
      <apex:commandButton action="{!doSearch}" value="Search" rerender="table">               
  <apex:pageBlockSection >
   <apex:inputField value="{!User.ManagerId}" id="Manager"/>
  <apex:pageBlockTable value="{!results}" var="t" id="table">
        <apex:column >
          <apex:inputCheckbox value="{!User.ManagerId}" id="checkedone">
        <apex:column value="{!t.Name}"/>
        <apex:column value="{!t.Email}"/>
        <apex:column value="{!t.Region__c}"/>
        <apex:column value="{!t.Manager__c}"/>
  <apex:commandButton action="{!getSelected}" value="UpdateManager" />




public class UserData {
List<Userwrapper> userList {get;set;}
PUBLIC String usr{get;set;}
PUBLIC List<selectOption> usrs;
List<User> results=new List<User>();
public User user;
  public UserData(ApexPages.StandardController controller)
     this.user= (User)controller.getRecord();
  public Pagereference doSearch()
      results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:User.Region__c];
      system.debug('USERSLISTFOR REGION$$$$'+results);
      return null;
  public List<Userwrapper> XXX() 
     if(userList == null) {
      userList = new List<Userwrapper>();

     for(User u:results)
        userList.add(new Userwrapper(u));
       return userList;

    // This method is called for 'UpdateManager' command button action, which is not getting invoked when clicked on the button . 
   Public PageReference getSelected()
        system.debug('ENTERED INTO SELECTED');
        List<User> selectedUsers = new List<User>();
        for(userwrapper usrwrapper : XXX())
          if(usrwrapper.selected == true)
        return null;
   Public Pagereference UpdateManager()
        return null;
   public List<User> getResults()
        return results;

Ranjeet Singh (SFDC Developer)Ranjeet Singh (SFDC Developer)

Try this code:  <apex:commandButton action="{!Selected}" value="UpdateManager" />


Dont use the get in action expression. i dont think it is required. use simply method name exclude with get in the vf page.. but must use get with method name in Controller.