views:

24

answers:

1

Hi

I'm a Java novice but am trying to produce a wizard using the Wizard class (org.eclipse.jface.wizard.Wizard)

Basically where I extend the Wizard in the constructor I addPage the two pages I want.

On my first page I take some credentials.

On the second page I want to run a query against the database using the credentials from the first page to populate a table with names.

How do I go about passing these values from the first to the second page?

To all intents and purposes my code at present is the same as http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Asurveyusingawizard.htm except I obtain some strings from some text boxes on the first page and have a table on the second page.

I have read about containers and see there is a setData() method, is this something I can utilize?

Kind regards in advance

David

A: 

I like to create my data object in the Wizard and pass it into the constructor of each of my WizardPages. For example:

public void addPages() {
  data = new MyData()
  addPage(new FirstPage(data));
  addPage(new SecondPage(data));
  ...
}

One advantage to this approach is you have access to your data object during your wizard's performFinish.

rancidfishbreath
Thanks, thats so obvious I'd overlooked it. Pretty silly of me...
David