Hi folks,
coming from the struts world, i need to get used to Wicket models. I
am still unsure if I use them correct, so i would like to ask about
the correctness of my code and hopefully learn more about models.
super(id, new CompoundPropertyModel<ValueMap>(new ValueMap()));
List<SelectOption> options = new ArrayList<SelectOption>();
options.add(new SelectOption("&", "AND"));
options.add(new SelectOption("!", "OR"));
ChoiceRenderer<SelectOption> choiceRenderer = new
ChoiceRenderer<SelectOption>("value", "key");
PropertyModel<SelectOption> propertyModel = new
PropertyModel<SelectOption>(getModel(), "parentproject");
DropDownChoice<SelectOption> ddc =
new DropDownChoice<SelectOption>(
"parentproject",
propertyModel,
options, choiceRenderer);
add(ddc);
This works well so far.
Now to my questions. I added the compoundPropertyModel to my page in
first line. It means a new ValueMap is available with the getModel()
method. And it means my page is stateful from now on. Correct?
For my DropDownBox I wrapped a specifica part of my CompoundModel,
namely the parentproject. If I imagine, with the call above I use the
key "parentproject" in my ValueMap for a SelectOption object.
Putting this in DropDownChoice, it means my value gets filled into my
getModel() at the slot "parentproject"
That being said, my CompoundPropertyModel is cared about from Wicket
in terms of memory and everything. I don't need to clean up here,
because it will become detached when the game is over.
Its fine to wrap the compoundmodel into a propertymodel in my case,
because I can store my value in the page model and make sure it will
stored at the slot I like.
Are my assumptions correct?
Thanks!
Best regards,
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]