+ Start a Discussion
csbaacsbaa 

controller.getSelected() not returning the nr of selected records

Hello Helper

 

 

I am having a problem with controller.getSelected();    apex code

 

I have a simple visual  force  page  and an extension class

 

I have a custom button  on a related list  of an object

 

I want to select a few items  on the related list  and perform a mass update on the selected  child  records

 

in the constructor  of the extension class  I call:

 

public MyExtensionClass(ApexPages.StandardSetController controller)

{

 

...

MyChildCustomObject[] EAs = controller.getSelected();

 

if(EAs.size() == 0)
{
SerrMsg = 'Select at least 1 event attendee to update.';
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,SerrMsg));
errorMsg = true;
return;
}

 

 

..

 

 

}

 

the size  of the EAs  array is always  0

 

 

I am missing something?

 

Regards

Csaba

 

 

 

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Starz26Starz26

Based on the code snippet you have....

 

nothing is selected when the page is loaded so having the code in your contructor will always have nothing selected

All Answers

Starz26Starz26

Based on the code snippet you have....

 

nothing is selected when the page is loaded so having the code in your contructor will always have nothing selected

This was selected as the best answer
csbaacsbaa

Thank  you

 

I will keep this i my mind

 

Regards

csbaa