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
goosegoose 

designing a wizard - problems navigating

Hi,

I have a problem with som code I'm developing. I'm not sure if it's down to my apex code, visualforce code or something else - so thought it best to post it here. Sorry if it's the wrong place.

I'm writing a visualforce wizard - based on the standard sample wizard in the documentation: http://wiki.apexdevnet.com/index.php/NewOpportunityController.apex

Most of it seems to be working though the problem is when selecting a number of contacts via a "apex:selectCheckboxes". On this wizard page, both the prev and next buttons return to the current page and not the pages appropriate.

Rather than post the whole code, here's samples;

The button controller code is:


Code:
   public PageReference step0() {
      return Page.bookingwiz0;
   }

   public PageReference step1() {
      return Page.bookingwiz1;
   }

   public PageReference step2() {
      return Page.bookingwiz2;
   }

 
Page bookingwiz0 has the vf code:


Code:
<apex:page controller="bookingWizController">
  <apex:sectionHeader title="Confirm Flight Booking" subtitle="Step 0 of 7"/>
    <apex:form >
      <apex:pageBlock title="Define Flight Name" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!step1}" value="Next"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Set Flight">
            <apex:inputField id="flight" value="{!flight.name}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection title="Test pick account">
            <apex:inputField id="account" value="{!flight.Flight_Account__c}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>

 
- which works fine. The 'getters' (I believe is the term) in the controller are:

Code:
   Account account;
Flight__c flight;

public Account getAccount() {
if(account == null) account = new Account();
return account;
} public Flight__c getFlight() { if(flight == null) flight = new Flight__c(); return flight; }

 

Now, the problem is with the next page. This picks a list of passengers from the account's contacts. (They will later be assigned to the flight as m:m objects but for now, they are just stored in the controller as an array of contacts).

Code:
<apex:page controller="bookingWizController">
  <apex:sectionHeader title="Confirm Flight Booking" subtitle="Step 1 of 7"/>
    <apex:form >
      <apex:pageBlock title="Add Passengers" mode="edit">
        <apex:pageBlockButtons >
        
            <apex:commandButton action="{!step0}" value="Previous"/>
            <apex:commandButton action="{!step2}" value="Next"/>
        </apex:pageBlockButtons>
            <apex:pageBlockSection title="Available Passengers" columns="1">
                <apex:selectCheckboxes value="{!passengers}" layout="pageDirection">
                    <apex:selectOptions value="{!passengeritem}"/>
                </apex:selectCheckboxes>
            </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>

 Now, I did a similar getter and got a read only error message. So I searched for the problem and the solution seemed to be to create a setter too:

Code:
   Contact[] passengers;

   public Contact[] getPassengers() {
       return passengers;
   }
   
   public void setPassengers(Contact[] passengers) {
        this.passengers = passengers;
   }




public List<SelectOption> passengeritemList;

public List<SelectOption> getPassengeritem() {
if (passengeritemList== null) {
List<Contact> contcs= [select id,firstname,lastname from Contact where Contact.Account.id = :flight.Flight_account__c];

passengeritemList= new List<SelectOption>();
for (Contact c : contcs) {
passengeritemList.add(new SelectOption(c.id, c.lastname + ' ' +c.firstname));
}
}
return passengeritemList;
}

 

It behaves as expected on page '0' - but on going to page '1' - either selecting or not selecting contacts from the list - neither the previous or next buttons go to the previous or next pages. The screen is rerendered - so it looks like the buttons are working - but it re-appears on page '1'.

Any ideas folks?

Thanks



Andrew8230Andrew8230
You most likely have some kind of issue/error on the page with one or more of the components. Try removing some components and see if you can get it to work.
goosegoose
Thanks - you were right - I picked up a problem on the system log.