• JennaB
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies

It seems like this should be simple, but...

I have created a custom controller that selects sessions and their related speakers. I have a visualforce page that displays this information. All is working fine, but I need to get it moved to production. I've been reading about testing and searching the discussions but I can't get what exactly I need to test for, since my controller doesn't do anything, as far as writing any records, there are no buttons or input accepted on the visualforce page, nothing is passed in the url, it simply displays a list of sessions and speakers. I really need to get a test written so I can get this moved out of sandbox - can anyone help? Any suggestions are appreciated! Thank you.

Below is the controller and page.

 

public class SessionListingController
{
    public String pitem { get; set; }
    Public List<WrapperSession> mainListSession {get;set;}
    Public List<Speaker__c> lstSpeaker {get;set;}
        
    public  SessionListingController()
    {
    mainListSession = new List<WrapperSession>();
    
    for (Session__c a : [SELECT id, name,Session_End_Time__c, Session_Abstract__c,
       Session_Code__c, Session_Start_Time__c, Session_Start_Date_Time__c,
            (SELECT Name, NameTitle_Org_St__c, Web_Speaker__c,  Speaker__c.Contact__r.Photo__c FROM speaker__r 
             WHERE Web_Speaker__c = 'CONFIRMED' ORDER BY Speaker_Order__c) 
       FROM session__c 
       WHERE Session__c.Event__r.Name = 'My Test Meeting' And Published__c = True
           ORDER BY Session_Start_Date_Time__c, Session_Code__c]) 
    {
    WrapperSession wrapSess = new WrapperSession();
    wrapSess.sess = a;
    Speaker__c[] speakers = a.speaker__r;
    lstSpeaker = new List<Speaker__c>();
    For(Speaker__c speaker : speakers)
    {
        lstSpeaker.add(speaker);
    }
   
    wrapSess.speaker = lstSpeaker;
    mainListSession.Add(wrapSess);
    }

    
    }
    public class WrapperSession     // this is the wrapper class
    {
    public Session__c sess{get;set;}     //to capture the Session
    public List<Speaker__c> speaker {get;set;}  // to capture the related Speaker
    }
    
     
}

 VF page:

 

<apex:page standardStylesheets="false" showHeader="false" sidebar="false" Controller="SessionListingController" cache="false">
  <apex:outputText value="Meeting Sessions" />
   <apex:dataTable value="{!mainListSession}" var="lw" >
       <apex:column headerValue=" ">
       <br></br>
       <apex:outputField value="{!lw.sess.Session_Start_Time__c}"/><br></br>
       <strong><apex:outputField value="{!lw.sess.Name}" /></strong>
       <br></br><apex:outputField value="{!lw.sess.Session_Abstract__c}" />
       <apex:outputPanel rendered="{!lw.sess.Session_Abstract__c!=''}"> <br /></apex:outputPanel>
       
       <apex:dataTable value="{!lw.speaker}" var="lwNote">
            <apex:column headerValue="  "  >
            <apex:outputField value="{!lwNote.NameTitle_Org_St__c}"  />
            </apex:column> 
       </apex:dataTable>
      </apex:column>
  </apex:dataTable>
</apex:page>

 

 

 

  • March 08, 2011
  • Like
  • 0

It seems like this should be simple, but...

I have created a custom controller that selects sessions and their related speakers. I have a visualforce page that displays this information. All is working fine, but I need to get it moved to production. I've been reading about testing and searching the discussions but I can't get what exactly I need to test for, since my controller doesn't do anything, as far as writing any records, there are no buttons or input accepted on the visualforce page, nothing is passed in the url, it simply displays a list of sessions and speakers. I really need to get a test written so I can get this moved out of sandbox - can anyone help? Any suggestions are appreciated! Thank you.

Below is the controller and page.

 

public class SessionListingController
{
    public String pitem { get; set; }
    Public List<WrapperSession> mainListSession {get;set;}
    Public List<Speaker__c> lstSpeaker {get;set;}
        
    public  SessionListingController()
    {
    mainListSession = new List<WrapperSession>();
    
    for (Session__c a : [SELECT id, name,Session_End_Time__c, Session_Abstract__c,
       Session_Code__c, Session_Start_Time__c, Session_Start_Date_Time__c,
            (SELECT Name, NameTitle_Org_St__c, Web_Speaker__c,  Speaker__c.Contact__r.Photo__c FROM speaker__r 
             WHERE Web_Speaker__c = 'CONFIRMED' ORDER BY Speaker_Order__c) 
       FROM session__c 
       WHERE Session__c.Event__r.Name = 'My Test Meeting' And Published__c = True
           ORDER BY Session_Start_Date_Time__c, Session_Code__c]) 
    {
    WrapperSession wrapSess = new WrapperSession();
    wrapSess.sess = a;
    Speaker__c[] speakers = a.speaker__r;
    lstSpeaker = new List<Speaker__c>();
    For(Speaker__c speaker : speakers)
    {
        lstSpeaker.add(speaker);
    }
   
    wrapSess.speaker = lstSpeaker;
    mainListSession.Add(wrapSess);
    }

    
    }
    public class WrapperSession     // this is the wrapper class
    {
    public Session__c sess{get;set;}     //to capture the Session
    public List<Speaker__c> speaker {get;set;}  // to capture the related Speaker
    }
    
     
}

 VF page:

 

<apex:page standardStylesheets="false" showHeader="false" sidebar="false" Controller="SessionListingController" cache="false">
  <apex:outputText value="Meeting Sessions" />
   <apex:dataTable value="{!mainListSession}" var="lw" >
       <apex:column headerValue=" ">
       <br></br>
       <apex:outputField value="{!lw.sess.Session_Start_Time__c}"/><br></br>
       <strong><apex:outputField value="{!lw.sess.Name}" /></strong>
       <br></br><apex:outputField value="{!lw.sess.Session_Abstract__c}" />
       <apex:outputPanel rendered="{!lw.sess.Session_Abstract__c!=''}"> <br /></apex:outputPanel>
       
       <apex:dataTable value="{!lw.speaker}" var="lwNote">
            <apex:column headerValue="  "  >
            <apex:outputField value="{!lwNote.NameTitle_Org_St__c}"  />
            </apex:column> 
       </apex:dataTable>
      </apex:column>
  </apex:dataTable>
</apex:page>

 

 

 

  • March 08, 2011
  • Like
  • 0

Hello all,

 

I have a requirement for a visualforce page which would repeat tables of account related information. Now i can do this easily if its just an object with one single related object. However if i have for example an Account, then a related object, then an object related to that related object i find that it becomes a little more challenging because soql can only return 1 inner object. 

 

So, i know a wrapper class is the suggested resolution to this problem. However they are very poorly documented and i cannot 'wrapper' my head around them. lol terrible i know. For instance i don't know how i can build a list with all of these related objects to use in the visual force page.

 

So if someone could please walk me (and i'm sure countless others) through this process that would be greatly greatly appreciated. 

 

Here is what i'm trying to do:

 

Relating multiple=

 



Hi all,

 

Quite a few of you have asked me about the availability of CMSForce 2.

I'm very happy to announce that you can now find it on the AppExchange. On the listing you'll find a short demo video that will get you up to speed on the new features. (central management console, folders to organize your content, in-site editing, friendly urls, ...)

 

I'll also include a shameless plug here : If you want to see it in action 'live', come to my 'Increase Lead Volume with Compelling Landing Pages' session on wed 8 at DreamForce.

 

Hope to see you there! In the meantime : if you have questions, just drop them in community boards.

 

David