|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Wizard questionI'm relatively new to wicket and have question about the wizard
implementation. It seems all the steps added to the Wizard in its constructor are themselves constructed when init is called on the Wizard. What I would like to do is have a mechanism for dynamically changing the second step in my wizard so that an arbitrarily sized editable list is displayed. Say step one was "How many events would you like to create," step two would be a list that corresponded in size to the answer provided in step one. What's the best way to approach this? I'm using 1.3.3 and a panel style wizard. Thanks. Ed. |
|
|
Re: Wizard questionEdward,
You could try something like: class Step1 extends WizardStep { public Step1() { super("Step 1", "How many?"); add(new TextField("numberOfThings")); } }; class Step2 extends WizardStep { public Step2() { super("Things", "Now Enter As Many 'Things' As You Opted For"); add(new Loop("things", new ComponentPropertyModel("numberOfThings")) { @Override protected void populateItem(LoopItem item) { IModel model = thingModel(item.getIteration()); // create model or reuse existing item.add(new TextField("thing", model)); } }); }; } ... where some ancestor has a CompoundPropertyModel whose model object has a "numberOfThings" property and this model object's setNumberOfThings method may also manage a list of models backed by "thing"s. Does that make sense? Hej core devs, I was wondering when I'd use the Loop class - is this a decent abuse of it?! Regards - Cemal http://jWeekend.co.uk
|
|
|
Re: Wizard question> You could try something like:
> > class Step2 extends WizardStep { > public Step2() { > super("Things", "Now Enter As Many 'Things' As You Opted For"); > add(new Loop("things", new > ComponentPropertyModel("numberOfThings")) { > @Override > protected void populateItem(LoopItem item) { > IModel model = thingModel(item.getIteration()); // > create model or reuse existing > item.add(new TextField("thing", model)); > } > }); > }; > } Yeah, something like that should work. Also, take a look at the org.apache.wicket.extensions.wizard.dynamic package for when your wizard steps need to be completely dynamic. > Hej core devs, I was wondering when I'd use the Loop class - is this a > decent abuse of it?! Sure. In general, I'd opt for ListView or another repeater, but if things are really as simple to have only a few steps, no other model, this is fine. Eelco --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free Forum Powered by Nabble | Forum Help |