I'm trying to save a checkbox value (and eventually a pulldown list of invitee status) with a standard Save button but all it does is refresh the page. I want to update the custom object Event_Attendance__c with the status and Attended checkbox. Here is the code:
<apex:page standardController="Event_Attendance__c" extensions="InviteeListController">
<apex:sectionHeader title="Event Attendance" subtitle="{!eventDate} - {!eventName}"/>
<apex:pageBlock title="Invitees" mode="edit">
<apex:form >
<apex:actionFunction name="getInvitees" action="{!InsertInvitees}" rerender="allPanel" />
<apex:outputPanel id="allPanel">
<apex:outputPanel rendered="{!NOT(myFlag)}">
<script>
window.onload=function()
{
getInvitees();
};
</script>
</apex:outputPanel>
<apex:outputPanel rendered="{!NOT(myFlag)}">
<apex:pageBlockTable value="{!eventinvitees}" var="eventinvitee">
<apex:column value="{!eventinvitee.Relation_id__c}"/>
<apex:column headerValue="Invitation Status" value="{!eventinvitee.Status__c}"/>
<apex:column headervalue="Attended">
<apex:inputCheckbox value="{!eventinvitee.Attended__c}"/>
</apex:column>
</apex:pageBlockTable>
<apex:commandButton action="{!Save}" value="Save"/>
</apex:outputPanel>
</apex:outputPanel>
</apex:form>
</apex:pageBlock>
</apex:page>
Here is the controller code: public with sharing class InviteeListController {
string eventid=ApexPages.currentPage().getParameters().get('event_id');
public string eventName {
get {eventName = ApexPages.currentPage().getParameters().get('event_name');
return eventName; }
private set;
}
public string eventDate {
get {eventDate = ApexPages.currentPage().getParameters().get('event_date');
return eventDate; }
private set;
}
public Boolean myFlag{get; set;}
public InviteeListController(ApexPages.StandardController controller) {
myFlag=false;
}
public void InsertInvitees()
{
if (!myFlag) { Integer inviteecount = [SELECT COUNT() FROM Event_Attendance__c WHERE EventID__c = :eventid]; if (inviteecount== 0){
getinvitees= [SELECT RELATIONID, EVENTID, STATUS, RESPONDEDDATE, RESPONSE FROM EventRelation WHERE EVENTID = :eventid];
List<Event_Attendance__c> insertinvitees = new List<Event_Attendance__c> ();
for (EventRelation a : getinvitees){
Event_Attendance__c ea = new Event_Attendance__c();
ea.EventID__c = a.EVENTID;
ea.Relation_id__c = a.RELATIONID;
ea.Status__c = a.Status;
ea.Event__c = eventName;
insertinvitees.add(ea);
}
insert insertinvitees;
myFlag = True;
}
}
eventinvitees= [Select Status__c, Attended__c, Relation_id__c, EventID__c, Event__c FROM Event_Attendance__c WHERE EventID__c = :eventid ];
}
public List<Event_Attendance__c>eventinvitees{get; set;}
public List<EventRelation>getinvitees{get; set;}
}