Hello, Wicket people.
I'm trying to construct a form which displays certain panel in case user
made a particular choice on the RadioChoice component.
Shortly speaking, there're two radiobuttons: TypeA and TypeB. If user
selects TypeB, an additional Panel must to be displayed. Although I got
pretty confused about my misunderstanding of how models work, so now I'm
just playing with them, trying to get it.
So, I have a MyPage which looks like this:
MyPage extends WebPage {
private String type;
private static final List TYPES = Arrays.asList(String[] { "TypeA",
"TypeB" });
MyPage() {
...
RadioChoice typeRadioChioce = new NotifiedRadioChoice("type", new
PropertyModel(this, "type"), TYPES);
form.add(typeRadioChoice);
...
String currentType = getType();
String currentType2 = typeRadioChoice.getModelObjectAsString();
System.out.println(currentType);
System.out.println(currentType2);
form.add(new Label("typeValue", new PropertyModel(this, "type"));
}
public String getType() {...}
public void setType(String type) {...}
}
When I load the page, "TypeA" is selected. When I hit "TypeB", the page
reloads. Now the "typeValue" label displays correct value, "TypeB", but two
printouts say "TypeA".
Why does this happens? Isn't type object of the page must be updated since
PropertyModel is used?
--
sp