Hi,
We are using Wicket in our project and here is one problem we found
during the development: There is one page with many fields, including
some text fields and some radio groups. Of course there are some
validators added to some fields. During the form submission, if any
validation fails, you will go back to the same page again. However,
the selection you made on the radio group is blanked out! It doesn't
happen to other fields but just radio group.
In order to verify it, I made a simple wicket page to do the test.
This is the Java file:
public class Example extends WebPage {
private String value;
private String value2;
private String selected;
public Example() {
super();
FeedbackPanel fb = new FeedbackPanel("feedback") ;
fb.setOutputMarkupId(true);
add(fb);
Form form = new Form("form1") {
@Override
public void onSubmit() {
info("Text field:"+Example.this.value+" Radio
selection:"+Example.this.selected);
}
};
add(form);
TextField field = new TextField("txtfield", new
PropertyModel(this, "value"));
field.setRequired(true);
form.add(field);
form.add(new TextField("txtfield2", new PropertyModel(this,
"value2")));
RadioGroup group = new RadioGroup("roles", new
PropertyModel(this,
"selected"));
form.add(group);
List<String> roles = getRoles();
// add all roles
ListView<String> rolesList = new ListView<String>("radioList",
roles){
protected void populateItem(ListItem<String> item) {
String bean = item.getModelObject();
item.add(new Radio("radio", item.getModel()));
item.add(new Label("name", bean));
}
};
group.add(rolesList);
form.add(new Button("submitButton"));
}
public List getRoles() {
List<String> list = new ArrayList<String>();
list.add("CEO");
list.add("CFO");
list.add("Director");
list.add("Manager");
list.add("Associate");
return list;
}
.. other getter/setter methods
}
The HTML file is as following:
<html>
<head>Testing page</head>
<body>
<p>Simple Testing Page for Wicket</p>
<div wicket:id="feedback" />
<br>
<form wicket:id="form1">
<table>
<tr>
<td>Enter a value:</td><td><input type="text" wicket:id="txtfield" /></td>
</tr>
<tr>
<td>Second text field:</td><td><input type="text" wicket:id="txtfield2" /></td>
</tr>
<tr>
<td>Groups:</td>
<td>
<div wicket:id="roles">
<ul>
<li wicket:id="radioList">
<input type="radio" wicket:id="radio" name="umcroles"
value="AFMS - Security Administrator" id="umcrroles_0" />
<label for="umcroles_0" wicket:id="name">Role name</label>
</li>
</ul>
</div>
</td>
</tr>
<tr>
</tr>
</table>
<p><input type="submit" wicket:id="submitButton" value="submit" />
</form>
</body>
</html>
Run this page, leave the first field blank and put any value in the
second field and choose a radio selection, submit the form, then you
will see that the value entered for the second field is there, but the
selection for the radio group is gone!
Could someone please confirm if this is a problem for Wicket, or I did
anything wrong here?
Thanks so much for the help in advance!
James Zhang
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]