You need to sign in to do that
Don't have an account?
sreeja
and display in the visualforce page;
<apex:outputfiled>
did any body completed the trialhead challange i had stucked here to complete it
public class BusScheduleCache { private Cache.OrgPartition part; public BusScheduleCache (){ Cache.OrgPartition part = cache.org.getpartition('local.BusSchedule'); } public void putSchedule(String busLine, Time[] schedule){ Part.put(busLine, '12'); // Part.put(schedule, {5,6,7}); } public getSchedule(String busLine){ if (cachedvalue!= null) { return null; } else { return null; } } }
and display in the visualforce page;
<apex:outputfiled>
All Answers
Please try this code:
public class BusScheduleCache {
// Get partition
private Cache.OrgPartition part;
String partitionName = 'local.BusSchedule';
public BusScheduleCache () {
if(partitionName !=null){
Cache.OrgPartition orgPart = new Cache.OrgPartition(partitionName);
if(orgPart != null){
part = orgPart;
}
}
}
public void putSchedule(String busLine, Time[] schedule) {
if (part != null){
part.put(busline, schedule);
}
}
public Time[] getSchedule(String busLine) {
Time[] schedule = new List<Time>();
// Get a cached value
Object obj = part.get(busLine);
// Cast return value to a specific data type
Time t2;
if (obj != null) {
t2 = (Time)obj;
}
if (t2 != null) {
schedule.add(t2);
}
else {
Time t3 = Time.newInstance(8,0,0,0);
if (t3 != null){
schedule.add(t3);
}
Time t4 = Time.newInstance(17,0,0,0);
if (t4 != null){
schedule.add(t4);
}
}
return schedule;
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha