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
sfdcttslsfdcttsl 

Method calling is not working in the controller.

Hi,

 

My controller class is having two actions. One is search based on a picklist value. Other one is command button action based on the result of first action.

 

Command button action(second action) is not getting invoked when the first action is occured.

 

Indepently it is working fine. Only the command button action without the first action is working.

 

But these two should be dependent actions.

 

Please advise on the requorement.

sfdcfoxsfdcfox

I'm afraid your question is unclear. Can you post some example code?

sfdcttslsfdcttsl

<apex:page StandardController="User" Extensions="UserData" tabstyle="User" sidebar="false">
  <apex:form >
  <apex:pageBlock title="Select Users" id="USERSLIST" mode="edit">
    <h1>Update Sales Co-ordinator for the users in Particular Region</h1>
  <br></br>
  <br></br>
<apex:actionRegion >
<apex:outputLabel value="Select Region of the user: " for="viewlist" />
<apex:inputField id="startMode" value="{!User.Region__c}">
<apex:actionsupport event="onchange" action="{!doSearch}" rerender="theTable" />
</apex:inputfield>
</apex:actionRegion>
           <br></br>
   <apex:pageBlockTable value="{!results}" var="t" id="theTable">
        <apex:column >
          <apex:inputCheckbox value="{!User.ManagerId}" id="checkedone">
          </apex:inputCheckbox>
        </apex:column>
        <apex:column value="{!t.Name}"/>
        <apex:column value="{!t.Email}"/>
        <apex:column value="{!t.Region__c}"/>
        <apex:column value="{!t.Manager__c}"/>     
  </apex:pageBlockTable>
<apex:inputField value="{!User.ManagerId}" />

<!--THE BELOW MENTIONED COMMAND BUTTON ACTION IS NOT GETTING INVOKED--->
<apex:commandButton value="UpdateManager" Id="Update" action="{!getselected}" />
    </apex:pageblock>   
  </apex:form>
  </apex:page>

 

 

public class UserData {
List<Userwrapper> userList {get;set;}
PUBLIC String usr{get;set;}
List<User> results=new List<User>();
public User user;
public ApexPages.StandardController stdCtrl;
public UserData(ApexPages.StandardController controller)
   {
     stdCtrl=controller;

   }  
       
        
  public Pagereference doSearch()
     {
          results = [select Name,Region__c,Email,LanguageLocaleKey,Manager__c from User Where Region__c =:u.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));
      }
      system.debug('****ADDEDUSERS****'+userlist);
       }
       return userList;

  }
     //THIS METHOD IS NOT GETTING INVOKED.
   Public PageReference getSelected()
   {
          
        system.debug('ENTERED INTO SELECTED');
        List<User> selectedUsers = new List<User>();
        for(userwrapper usrwrapper : XXX())
        {
          if(usrwrapper.selected== true)
          {
           selectedusers.add(usrwrapper.wuser);
          }
        }
        system.debug('@@@SELECTEDUSERs@@@:'+selectedusers); 
        return null;
  }
   
    Public Pagereference UpdateManager()
   {
        return null;
   }
    
   public List<User> getResults()
    {
        return results;
    }
 
 }

 

If only the command button is clicked, then the action is invoked however no result is passed.

 

But if the first action is executed(picklist value selection) and then cliked on command button there the action is not getting invoked.

 

Please advice.