You need to sign in to do that
Don't have an account?
Justin D
How to apply this logic to display data in Visualforce page
I am not sure when/whether I should put logic inside Apex class or use Visualforce page to display data.
Here is logic.
Depending on the SurveySelection, it would display data (surveytype) differently.
Logic:
If (SurveySelection__c = 1) {
Surveytype__c = “final1” and “final2”
} else if (SurveySelection__c = 2) {
Surveytype__c = “midterm1” and “midterm2”
} else {
Surveytype__c = “openbooktest1” and “openbooktest2”
}
My question is: should I use If Statement inside APEX code like below or should I program inside VF page?
Here is some Apex code that I have:
Public PageReference searchStudents()
{
students = [ select
LName__c
, (select SurveySelection__c from SurveySelections__r )
From Student__c ];
surveyselections = [select
SurveySelection__c
From SurveySelection__c ];
surveyreference = [select
SurveyType__c
From SurveyReference__c ];
Return null;
}
Here is logic.
Depending on the SurveySelection, it would display data (surveytype) differently.
Logic:
If (SurveySelection__c = 1) {
Surveytype__c = “final1” and “final2”
} else if (SurveySelection__c = 2) {
Surveytype__c = “midterm1” and “midterm2”
} else {
Surveytype__c = “openbooktest1” and “openbooktest2”
}
My question is: should I use If Statement inside APEX code like below or should I program inside VF page?
Here is some Apex code that I have:
Public PageReference searchStudents()
{
students = [ select
LName__c
, (select SurveySelection__c from SurveySelections__r )
From Student__c ];
surveyselections = [select
SurveySelection__c
From SurveySelection__c ];
surveyreference = [select
SurveyType__c
From SurveyReference__c ];
Return null;
}
In your specific example - you might think about just making a text formula field and display that field. That would keep the login in the point and click portion of salesforce, and make the apex and VF simplier.
Always try doing this in Apex, I would suggest if this is a routine process that you want to use in multiple places then its even better putting this piece of Code in some Static Utility Method and call it from you Apex Controller