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
dedkinsdedkins 

Dynamically Update a Set Method?

I've been able to leverage the CalendarSimple code for our needs - however, I'm running into a challenge and can't figure out a way to make it work without creating several different pages to rerender based on input.

 

VF Page - combines two includes.  On the left I have a list of people that I can select from, on the right I have a calendar with associated open slots of time.  When a person is selected, it refreshes the right side (calendar) with all available slots of time using two variables passed in the url.  I'd like to allow the user to change the calendar view (availability) based on certain criteria after the screen has refreshed.  The code:

 

public CalendarMonth getMonth() { return month; } 

 

private void setMonth(Date d) {
month = new CalendarMonth(d);
system.assert(month != null);

Date[] da = month.getValidDateRange(); // gather events that fall in this month
events = [ select id,subject,availability__c,description,activitydate,activitydatetime,DurationInMinutes
from Event
where activitydate >= :da[0] AND activityDate <= :da[1] AND availability__c = 'Available' AND location__c = 'San Diego'
order by activitydatetime];

month.setEvents(events); // merge those events into the month class
}

 

I'd like to be able to dynamically add or change the blue text based on commandlinks on the page - without refreshing and losing the params that have been passed. 

 

How can I dynamically update a set method?

 

Thank you.

Dave

 

sfdcfoxsfdcfox

1) Create variable in your controller:

 

private string location;

2) Initialize the values with your desired defaults:

 

// in constructor;
location = 'San Diego';

3) Change your query to use the new value:

 

// SELECT part here
WHERE ActivityDate >= :da[0] AND ActivityDate <= :da[1] AND Availability__c = 'Available' AND Location__c = :location
// Rest of query here

4) Create action functions to change the value:

 

public void locationSanFrancisco() {
    location = 'San Francisco';
    setMonth(/* use date variable */);
}