You need to sign in to do that
Don't have an account?
How to create attendee register where there are a dynamic number of sessions
I have created the following database/object scheme: http://www.gliffy.com/publish/1673148/
I am trying to create a dynamic register to allow the marking of attendees(Contacts) as attending or not a given event session for an event.
I have writen some SOQL that returns the data that I require and have created a controller that reurns this data as a list.
However i have come to an issue when I try to use <apex:checkboxes> to allow the checking of applicants as attending a given event session. I get an error Invalid selectOptions found. Use SelectOption type in Apex. How can I do this can I combine 2 lists together?
Controller Code:
public class attendeesbyeventcontroller {
string eventID = System.currentPageReference().getParameters().get('id');
public string eventsessions { get; set;}
public List<App__c> getApplicant() {
return [Select a.name, a.Applicant__r.Email, a.Applicant__r.FirstName, a.Applicant__r.LastName, (Select Attended_Session__c From App_Sessions__r) from App__c a Where a.sbs_event__c = :eventid Limit 40];
}
}
Visualforce:
<apex:page controller="attendeesbyeventcontroller" tabStyle="App_Session__c" >
<apex:form >
<apex:pageblock id="thePage">
<apex:pageblocktable value="{!Applicant}" var="AE" id="candidateTable">
<apex:column value="{!AE.Applicant__r.FirstName}"/>
<apex:column value="{!AE.Applicant__r.LastName}"/>
<apex:column value=" {!AE.Applicant__r.Email}" />
<apex:column >
<apex:facet name="header">Event Sessions</apex:facet>
<apex:selectCheckboxes value="{!eventsessions}">
<apex:selectOptions value="{!AE.App_Sessions__r}"/>
</apex:selectCheckboxes>
</apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>
My 2nd concern is regarding governor limits on my SOQL query. Can anyone give me an idea on how many records would need to be returned before I would be hitting those governor limits?
You need to bind your checkboxes to a list of select option (List<SelectOption> ) in your controller.
See the docs at :
http://www.salesforce.com/us/developer/docs/pages/Content/apex_pages_selectoption.htm?SearchType=Stem&Highlight=selectOptions|selectOption|SelectOption|SelectOptions
David
Hi David,
Thanks I gathered that I had to put the checkboxes into a List<selectOptionlist>. But How do I add this dynamicly in a pageblocktable that is returning other details. ie for each row of the pageblocktable I will need to create a different List<SelectOption> list?
Thanks
Don't know if it will work but you could try creating a wrapper class in which you put the object for each row + a List of SelectionOptions. Dump all these wrapper classes in a List and iterate over that with you datatable.
David