FelixPreussner (4) [Avatar] Offline
#1
Hi,
I'm trying to build a wicket wizard for a web application I'm working on. Using this wizard, a user should be able to write an article about something, tag it with different parameters like a titel and an abstract and on the last step save the artikel to a database. The code kinda looks like this:

private final class ChooseModeStep extends WizardStep {
public ChooseModeStep()
{

IModel<Artikel> artikelModel = new Model<Artikel>(artikel);

setTitleModel(new ResourceModel("ChooseModeStep.titel"));
setSummaryModel(new StringResourceModel("ChooseModeStep.summary", this, artikelModel));
List<String> choices = Arrays.asList("Upload File", "Write Artikel");
add (new RadioChoice("artikel.chooseMode", new PropertyModel(artikelModel, "chooseMode"), choices));
}
}


public NewArtikelWizard(String id)
{
super(id);

// create a blank artikel
artikel = new Artikel();

setDefaultModel(new CompoundPropertyModel<NewArtikelWizard>(this));
WizardModel model = new WizardModel();

model.add(new TagArtikelStep());
model.add(new ChooseModeStep());
model.add(new UploadArtikelStep());
// initialize the wizard with the wizard model we just built
init(model);
}

My Question is, how can I access the users' input form a different Wizard Step? What I want to do is, have the user select one of the radio buttons on the shown step. If the user selectes the first button, he will be redirected to a different step, than if he would have selected the second button. I have been sitting on that problem for hours. Probably there is just one thing, I don't understand about models.

Thank you very much

Felix
FelixPreussner (4) [Avatar] Offline
#2
Re: Problem with wicket wizard
To make my Question a little clearer:

I have a textField on WizardStep1:

RequiredTextField<String> titel = new RequiredTextField<String>("artikel.titel");
add(titel);

On WizardStep2 I have a label that displays the input of the textField from WizardStep1:

PropertyModel theTitel=new PropertyModel(artikelModel, "titel");
add (new Label("label", theTitel));

This works so far. If I enter "this is the titel" in the textField, it is displayed by the lable.

Now I want to save the input of the textField to a String. Is that possible?

Felix
Eelco12 (100) [Avatar] Offline
#3
Re: Problem with wicket wizard
Your input should be saved to artikel.titel. If you want to save to a String instead, use an object with a string property with your model and let the model update that.

As for deciding which steps to go to dynamically... skipping steps is easy with the regular wizard, but for anything more fancy, consider using DynamicWizardModel.
FelixPreussner (4) [Avatar] Offline
#4
Re: Problem with wicket wizard
> Your input should be saved to artikel.titel. If you
> want to save to a String instead, use an object with
> a string property with your model and let the model
> update that.

Thank you very much for your answer, but could you give me a hint how to do that?
Eelco12 (100) [Avatar] Offline
#5
Re: Problem with wicket wizard
Instead of articleModel, pass in a model with any object that has a string property and work with that?

Or do you want to keep using articleModel but on top of that save the string to other places? In that case, you could for instance just get the string in the step's applyState.

A better place for questions like these is the Wicket user list (see: http://wicket.apache.org/community.html), where you potentially have a lot more people joining in.
FelixPreussner (4) [Avatar] Offline
#6
Re: Problem with wicket wizard
Thank you Eelco! I finally used the FormValidator to get what I wanted.