+ Start a Discussion

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:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField id="accountName" value="{!opportunity.AccountId}"/>




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?



return Page.opportunitydecisiontree2;
public PageReference save() {
insert opportunity;
PageReference opptyPage = new PageReference('/' +
return opptyPage;




Can anyone help me with this?