With http://issues.apache.org/jira/browse/WICKET-136 you could do:
class PhoneNumber extends FormComponentPanel {
private String one;
private String two;
TextField oneField;
TextField twoField;
public PhoneNumber(String id, IModel m) {
super(id, new CompoundPropertyModel(this));
add(one = new TextField("one"));
add(two =new TextField("two"));
}
public void updateModel() {
oneField.updateModel();
twoField.updateModel();
Person p = (Person)getModelObject();
p.setWork(one);
p.setCell(two);
}
}
With http://www.nabble.com/traversing-form-components-tf2721406.html#a7589076
you wouldn't even need to call updateModel on you child components.
However, what I'm wondering is why make a panel with those three
numbers in the first place, while you could create a single number
panel that would be created like this:
new PhoneNumberPanel("workInput", pModel, "work"));
public PhoneNumberPanel(String id, IModel m, String property) {
super(id);
add(new TextField("foo", new PropertyModel(m, property)));
}
Eelco
On 12/14/06, Jonathan Sharp <[EMAIL PROTECTED]> wrote:
> I have a Page level Model:
> class Person {
> String work;
> String cell;
> }
>
> I have a component such as:
> class PhoneNumber extends Panel {
> class Phone {
> String one;
> String two;
> String three;
>
> public String toString() {
> return one + two + three;
> }
> }
>
> public PhoneNumber(String id, IModel m) {
> super(id, new Model(new Phone()));
> TextField one = new TextField("one", new
> PropertyModel(getModelObject(), "one"));
> TextField two = new TextField("two", new
> PropertyModel(getModelObject(), "two"));
> TextField three = new TextField("three", new
> PropertyModel(getModelObject(), "three"));
> }
> }
>
> On my page I'm doing:
> Person p = new Person();
> new PhoneNumber("workInput", new PropertyModel(p, "work"));
> new PhoneNumber("cellInput", new PropertyModel(p, "cell"));
>
>
> So how do I map the internal model for my panel ("Phone") to the passed in
> model?
>
> Cheers,
> -js
>
> -------------------------------------------------------------------------
> 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
> [email protected]
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user