raybristol wrote:
My WizardPage is like

public class AddDeliveryWizardPage extends AbstractExamplePage{
        
        public AddDeliveryWizardPage(){
                
                super();

                WizardModel model = new WizardModel();
                          int numberOfBoxes = 0;
                          List<Box> boxesList = new ArrayList<Box>();

                          //variable 'numberOfBoxes' will be set in this
step
                model.add(new SetNumberOfBoxesWizardStep());
        
                          //set box entity objects according to variable
'numberOfBoxes' set from last step
                model.add(new SetBoxEntityWizardStep(int numberOfBoxes));
                
                Wizard wizard = new Wizard("wizard", model)
                this.add(wizard);
        }

}

question 1: as model step is added at compile time, so I don't know how to
get the value of variable 'numberOfBoxes' after it got set from the 1st
step, in the 2nd step 'numberOfBoxes''s value is default value 0.
You should make numberOfBoxes variable accessible in both the steps. One way to do it:

public class AddDeliveryWizardPage extends AbstractExamplePage{
        
        private int numberOfBoxes;
       private final List<Box> boxesList = new ArrayList<Box>();

        public AddDeliveryWizardPage(){
                
                super();

                IModel boxesAmountModel = new PropertyModel(this, 
"numberOfBoxes");
                WizardModel model = new WizardModel();

                //variable 'numberOfBoxes' will be set in this step
                model.add(new SetNumberOfBoxesWizardStep(boxesAmountModel) {
                        public void applyState() {
                                for (int i = 0; i < numberOfBoxes; i++)
                                        boxesList.add(new Box());
                        }
                });
        
                //set box entity objects according to variable 'numberOfBoxes' 
set from last step
                model.add(new SetBoxEntityWizardStep(boxesAmountModel, 
boxesList));
                
                Wizard wizard = new Wizard("wizard", model)
                this.add(wizard);
        }

}

question 2: in the 2nd step I probably need user to input multiple box
object's details, for a single model, I can use somthign like setModel(new
CompoundPropertyModel(box)), but what about for multiple objects? is it
something like setModel(new CompoundPropertyModel(boxeslist))  <- boxeslist
is a arraylist of box objects.
Notice that I added a "boxesList" parameter for the second step in the code above. So then in the SexBoxEntityWizardStep you could use some repeater to generate html inputs for every box. For example here is a ListView example:

add(new ListView("boxes", boxesList) {
   protected void populateItem(final ListItem item) {
item.add(new TextField("name", new PropertyModel(item.getModelObject(), "name"));
   }
});

Many thanks for your guys help, this is the best forum I can find for wicket
:)

+1 :)


--
Andrew Klochkov


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to