Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "FAQ How do I specify the order of pages in a wizard?"

 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
In its simplest and most common form, a wizard is made up of a static, ordered  
+
In its simplest and most common form, a wizard is made up of a static, ordered list of pages.  A wizard adds pages to the list by using the <tt>Wizard.addPage</tt> method, and the '''Next''' and '''Back''' buttons simply cycle through this ordered list. For a wizard with a static set of pages, you can simply override the <tt>addPages</tt> method and add all of your pages at once. This snippet is from <tt>AddingWizard</tt> in the FAQ Examples plug-in:
list of pages.  A wizard adds pages to the list by using the <tt>Wizard.addPage</tt>
+
 
method, and the '''Next''' and '''Back''' buttons  
+
simply cycle through this ordered list.
+
For a wizard with a static set of pages, you can simply override the  
+
<tt>addPages</tt> method and add all of your pages at once. This snippet
+
is from <tt>AddingWizard</tt> in the FAQ Examples plug-in:
+
 
<pre>
 
<pre>
 
   public class AddingWizard extends Wizard {
 
   public class AddingWizard extends Wizard {
Line 21: Line 16:
 
</pre>
 
</pre>
  
 +
If you want to change the behavior of the wizard, depending on the values that are entered, you can dynamically create new pages or  change the page order after the wizard is opened.  Pages must still  be added to the wizard by using the <tt>addPage</tt> method, but  the progression of pages through the wizard can change, depending  on the user&#146;s input.  This ordering is changed by overriding the wizard methods <tt>getNextPage</tt> and <tt>getPreviousPage</tt>,  which are called when the user clicks on '''Next''' or  '''Back''' button.
  
 
+
Even with dynamic wizards, you must create at least one page before the wizard is opened. If only one page is added at the beginning, but more pages will be added later on, you will need to call <tt>Wizard.setForcePreviousAndNextButtons(true)</tt> before the wizard is opened.  Otherwise, the '''Next''' and '''Back''' buttons will appear only if more than one page is in the page list.
If you want to change the behavior of the wizard, depending on the
+
values that are entered, you can dynamically create new pages or
+
change the page order after the wizard is opened.  Pages must still
+
be added to the wizard by using the <tt>addPage</tt> method, but
+
the progression of pages through the wizard can change, depending
+
on the user&#146;s input.  This ordering is changed by overriding the
+
wizard methods <tt>getNextPage</tt> and <tt>getPreviousPage</tt>,
+
which are called when the user clicks on '''Next''' or
+
'''Back''' button.
+
 
+
 
+
 
+
 
+
Even with dynamic wizards, you must create at least one page  
+
before the wizard is opened. If only one page is added at the  
+
beginning, but more pages will be added later on, you will need to  
+
call <tt>Wizard.setForcePreviousAndNextButtons(true)</tt> before  
+
the wizard is opened.  Otherwise, the '''Next''' and  
+
'''Back''' buttons will appear only if more than one page is in the page list.
+
 
+
 
+
 
+
 
+
 
+
 
+
  
 
== See Also: ==
 
== See Also: ==
 +
*[[FAQ What is a wizard?]]
  
 
+
{{Template:FAQ_Tagline}}
[[FAQ_What_is_a_wizard%3F]]
+
 
+
 
+
[[FAQ_How_do_I_specify_the_order_of_pages_in_a_wizard%3F]]
+
 
+
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+

Latest revision as of 23:48, 7 June 2006

In its simplest and most common form, a wizard is made up of a static, ordered list of pages. A wizard adds pages to the list by using the Wizard.addPage method, and the Next and Back buttons simply cycle through this ordered list. For a wizard with a static set of pages, you can simply override the addPages method and add all of your pages at once. This snippet is from AddingWizard in the FAQ Examples plug-in:

   public class AddingWizard extends Wizard {
      private AddingWizardPage page1, page2;
      ...
      public void addPages() {
         page1 = new AddingWizardPage("Page1", 
            "Please enter the first number");
         addPage(page1);
         page2 = new AddingWizardPage("Page2", 
            "Enter another number");
         addPage(page2);
      }
   }

If you want to change the behavior of the wizard, depending on the values that are entered, you can dynamically create new pages or change the page order after the wizard is opened. Pages must still be added to the wizard by using the addPage method, but the progression of pages through the wizard can change, depending on the user&#146;s input. This ordering is changed by overriding the wizard methods getNextPage and getPreviousPage, which are called when the user clicks on Next or Back button.

Even with dynamic wizards, you must create at least one page before the wizard is opened. If only one page is added at the beginning, but more pages will be added later on, you will need to call Wizard.setForcePreviousAndNextButtons(true) before the wizard is opened. Otherwise, the Next and Back buttons will appear only if more than one page is in the page list.

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.