Code snippet
public PageReference openSheet(){
if (!strday.isNumeric()){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Pleaseenter a correct day value.'));
return null;
}
if (!strmonth.isNumeric()){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter a correct month value.'));
return null;
}
if (!stryear.isNumeric()){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter a correct year value.'));
return null;
}
PageReference newPage = page.crew_sheet;
strday.leftPad(2,'0');
strmonth.leftPad(2,'0');
newPage.getParameters().put('day', strday);
newPage.getParameters().put('month', strmonth);
newPage.getParameters().put('year', stryear);
newPage.setRedirect(true);
return newPage;
}
The Visualforce page that opens also has a custom controller and it uses the following code (snippet):
Page 2 Controller
public with sharing class CrewSheet {
Public String day;
Public String month;
Public String year;
Public Datetime specificDate;
functionalY fy = new functionalYUtilities ();
Public List<Object__c> listAlpha1{get;set;}
Set<String> gwRounds = new Set<String>();
Public List<WorkOrder> listAlpha1Results{get;set;}
Public List<Object__c> listAlpha2{get;set;}
Set<String> pcRounds = new Set<String>();
Public List<WorkOrder> listAlpha2Results{get;set;}
Public List<Object__c> listAlpha3{get;set;}
Set<String> gbRounds = new Set<String>();
Public List<WorkOrder> listAlpha3Results{get;set;}
Public List<Object__c> listAlpha4{get;set;}
Set<String> rRounds = new Set<String>();
Public List<WorkOrder> listAlpha4Results{get;set;}
Public CrewSheet(){
//get the parameters from the page
day = apexpages.currentPage().getParameters().get('day');
month = apexpages.currentPage().getParameters().get('month');
year = apexpages.currentPage().getParameters().get('year');
//the following if statements were added in as the test class isn't passing the parameters
Datetime missingdate = system.now();
if(day == ''){
day = string.valueof(missingdate.day());
}
if(month == ''){
month = string.valueof(missingdate.month());
}
if(year == ''){
year = string.valueof(missingdate.year());
}
String specificDate = day + '/' + month + '/' + year + ' 09:00';
Datetime specificDateformatted = datetime.parse(specificDate);
String nextDayText = specificDateformatted.format('EEEE');
// At this point we use the dates/strings in queries ultimately displayed on the vf page...i've cut them out for make it easier to read.
}
Thanks