Hello to all!
I'm beginning to learn how to use wicket and I have a question regarding
DropDownChoice: I have a POJO that is serving me as the model for my
page, so my form is bind to the properties.
My problem with the Dropdownchoice in this case is: even if the property
in the POJO is filled exactly with the same string as the dropdown, I
never have the proper value selected. It is always selecting that
"Choose One" option. So , the question really is: what I need to do to
have this working properly?
Follow below the source code for this situation:
public class User {
private String userName;
private String userType;
public User() {
this.userType = "General User";
}
/* getters/setters */
}
Now, I'll create a page and bind this POJO in the interface:
HTML:
<html>
<head><title>Test Page</title></head>
<body>
<form wicket:id="testForm">
User Name: <input type="text" wicket:id="userName"><br>
User Type: <select wicket:id="userType">
<option>Demo 1</option>
<option>Demo 2</option>
</select>
</form>
</body>
</html>
JAVA:
public class TestPage extends WebPage {
private String[] options = new String[] {new String("Test User"), new
String("General User")};
private List OPTIONS = Array.arrayAsList(options);
public TestPage() {
User user = new User();
CompoundPropertyModel userModel = new
CompoundPropertyModel(user);
Form testForm = new Form("testForm", userModel);
TextField userName = new TextField("userName");
DropDownChoice userType = new DropDownChoice("userType", new
PropertyModel(userModel,"userType"), OPTIONS);
testForm.add(userName);
testForm.add(userType);
add(testForm);
}
}
Regards,
Walter Ritzel, Developer
[EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user