fwiw a common pattern i use is to do the conversion in an model decorator
something like
class StringToPhoneModel implements IModel {
private final IModel stringModel;
public StringToPhoneModel(IModel stringModel) { this.stringModel=stringModel;
}
public Object getObject(Component c) { return new PhoneNumber(
stringModel.getObject(c); }
public void setObject(Component c, Object o) { stringModel.setObject(c,
((PhoneNumber)o).toString()); }
public void detach() { stringModel.detach(); }
}
-igor
On 12/14/06, Jonathan Sharp <[EMAIL PROTECTED]> wrote:
I believe I have it working as such:
class PhoneNumber implements Serializable {
private String one;
private String two;
public PhoneNumber(String str) {
// Parse str and set one and two
}
// setters & getters *snipped*
public String toString() {
return one + two;
}
}
public Phone(String id, IModel m) {
super(id);
phone = new PhoneNumber(m.getObject(this).toString());
m.setObject(this, phone);
add(new TextField("one", new PropertyModel(phone, "one")));
add(new TextField("two", new PropertyModel(phone, "two")));
}
And on my page I do:
add(new Phone("wicket:id", new PropertyModel(myObject, "theField")));
Cheers,
-Jonathan
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user