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
chriseustacechriseustace 

newbie to Apex - trying to display different info based on values

Hello all,

I am trying to develop a few visual force pages that based upon the Account State, I will redirect to different pages.

 

I have a basic page that allows the user to select an Account from a lookup

<apex:page controller="enerNOCController" tabStyle="Opportunity">
<apex:sectionHeader title="New Customer Opportunity"
subtitle="Step 1 of 2"/>

<apex:includescript value="{!$Resource.pageBlockSupplement}" />
    <apex:form >
        <apex:pageBlock title="My Content">
           <apex:pageBlockButtons >
                <apex:commandButton action="{!step2}" value="Next" styleClass="btn"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField id="accountName" value="{!opportunity.AccountId}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

 

I also have a controller that holds some of the logic.  What I am thinking is I can use if(account.State=="New York") then I'll do something

 

public class enerNOCController {
Opportunity opportunity;
Account account;

public Account getAcctName()
{
   return [select Name from Account limit 1];
}
public Account getAccount() {
if(account == null) account = new Account();
return account;
}
public Opportunity getOpportunity() {
if(opportunity == null) opportunity = new Opportunity();
return opportunity;
}
public PageReference step1() {
return Page.OpportunityDecisionTree;
}
public PageReference step2() {

//use account.State?

 

 

if(account.State){
return Page.opportunitydecisiontree2;
}
}
public PageReference save() {
insert opportunity;
PageReference opptyPage = new PageReference('/' +
opportunity.id);
opptyPage.setRedirect(true);
return opptyPage;
}
}

 

 

 

Can anyone help me with this?

Thanks!