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
Eager-2-LearnEager-2-Learn 

Please help with test script for VF page that references a list in the controller

Hi,

 

I wrote some code that uses a helper class and stores the items in a list which feeds the pageBlockTable on the VF page.  This helper class has a boolean which is my checkbox on the VF page.  How can I write the test class to check one of the records?  Not to over populate this post I have snippets of the VF and controller.  I am still struggling with test code scripts.  If you need me to post all the code in order for you to help me on this issue I can.

 

I'm not sure how I get the test class to check one of the records that show on the VF page.  I appreciate your help.  Mean while I will keep hacking a way at this!

 

VF PAGE:

<apex:pageblocktable value="{!UserChatterGroupList}" var="item" rowClasses="even,odd">
                <apex:column headervalue="Select Record" headerClass="ColumnHeaders" width="80">
                    <apex:inputcheckbox value="{!item.recordSelect}"/>
                </apex:column>

 

Controller Class:

public class CFCT_UsersNotInChatterGroups_Controller {
    public  String ChatterGroupsMissingMessage { get; set; }
    public  List<HelperClass> UserChatterGroupList { get; set; }
...
...
...
    // Helper Class
    public class HelperClass {
        public boolean recordSelect {get; set;}    
        public Id GroupId {get; set;}  
        public id UserId {get; set;}   
        public String UserName {get; set;}
        public String ChatterGroupName {get; set;}
    }
}

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Shailesh DeshpandeShailesh Deshpande
Not a clean solution but if you are sure that there are values present in your list, you can simply use UserChatterGroupList[0].recordSelect = true;

Likewise you can select few other elements in the list.

All Answers

Shailesh DeshpandeShailesh Deshpande
Not a clean solution but if you are sure that there are values present in your list, you can simply use UserChatterGroupList[0].recordSelect = true;

Likewise you can select few other elements in the list.
This was selected as the best answer
Eager-2-LearnEager-2-Learn
Sweet--that worked! I am struggling getting my head wrapped around the concept of testing with code! Thank you very much.