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
Rahul BorgaonkarRahul Borgaonkar 

Getter and Setter method for class sobject variable

Hi,

I am using a class
public class EventBookingRecs
{
        public sObject EventBooking {get; set;}
        public Account bookingAccount {get;set;}
        public Contact bookingContact {get;set;}
}
where variable EventBooking is based on custom object EventBooking already created. The custom object has fields like Name, Status__c etc. I am using EventBooking in visualforce page -> pageblocktable.
example
<apex:pageblocktable value="{!EventBookingRecords}" var="ebrecs" id="pbt">
       <apex:Column >
              <apex:facet name="header">Booking Status</apex:facet>
                    <apex:selectList id="status" onchange="saveValues({!ebrecs.index})" value="{!ebrecs.EventBooking['Status__c']}" size="1">
                        <apex:selectOption itemValue="" itemLabel=""/>
                        <apex:selectOption itemValue="Attended" itemLabel="Attended"/>
                        <apex:selectOption itemValue="No Show" itemLabel="No Show"/>
                    </apex:selectList>
       </apex:Column>
</apex:pageblocktable>

Could you please let me know how to write a getter and setter method for EventBooking['Status__c'] (EventBookingRecs.EventBooking.Status__c) so that when values changes on screen it should set it permamently and screen refresh should not affect it?

Please let me know if you need more details

Best Regards,

Rahul
Mudasir WaniMudasir Wani

Hello,

You are using EventBookingRecords in the VF page but I can't see it in the class.
You need to create a public list of your custom object and put the values in EventBookingRecords.
Hope this will help.
It should be like 
Public List<CustomObjectName__c> EventBookingRecords = [SOQL to fetch your object records];