You need to sign in to do that
Don't have an account?
Jon Gradman
create test class for visualforce controller - please help and eager to learn
Hi,
I'm pretty new to Visualforce, although I have coding experience in other languages. I've never built a test class for a custom controller before, and looking for some guidance. Here is the controller code:
Visualforce markup is:
The page gets put on the layout and shows contacts on a Parent Account record (shown on a child record).
Any help greatly appreciated, thanks in advance.
I'm pretty new to Visualforce, although I have coding experience in other languages. I've never built a test class for a custom controller before, and looking for some guidance. Here is the controller code:
public class ParentCntacts { public List<Account> accts {get;set;} public Account thisAcct {get;set;} public ParentCntacts() { thisAcct = [Select id, Name, ParentId FROM Account WHERE id = :ApexPages.currentPage().getParameters().get('id')]; } public List<Account> getCon() { accts = [SELECT id, Name, ParentId, (SELECT id, Name, Title, Main_CSM_Contact__c, Decision_Maker__c, No_Longer_At_Company__c, HasOptedOutOfEmail, Role_Contact_updated__c, Email, Phone, LinkedIn_Profile__c FROM Contacts) FROM Account WHERE Id = :thisAcct.ParentId]; return accts; } }
Visualforce markup is:
<apex:page controller="ParentCntacts" > <apex:pageBlock > <apex:repeat value="{!con}" var="a"> <apex:pageBlockSection ><b>{!a.Name}</b></apex:pageBlockSection> <apex:pageblockTable value="{!a.Contacts}" var="c"> <apex:column headerValue="Contact Name"> <apex:outputLink id="link" value="https://cs54.salesforce.com/{!c.Id}" target="_blank" >{!c.Name}</apex:outputLink> </apex:column> <apex:column value="{!c.Title}" /> <apex:column value="{!c.Main_CSM_Contact__c}" /> <apex:column value="{!c.Decision_Maker__c}" /> <apex:column value="{!c.No_Longer_At_Company__c}" /> <apex:column value="{!c.HasOptedOutOfEmail}" /> <apex:column value="{!c.Role_Contact_updated__c}" /> <apex:column value="{!c.Email}" /> <apex:column value="{!c.Phone}" /> <apex:column value="{!c.LinkedIn_Profile__c}" /> </apex:pageblockTable> </apex:repeat> </apex:pageBlock> </apex:page>
The page gets put on the layout and shows contacts on a Parent Account record (shown on a child record).
Any help greatly appreciated, thanks in advance.
Regards ,
Harish.R.
All Answers
Regards ,
Harish.R.
Cheers,
Jon