On Thu, 22 Jan 2009, Phillip Rhodes wrote:
> I used the page.get("componentid") method, but it returns null. While
> I could just store the reference to the label as a variable in my page
> class, I would like to understand how to obtain a reference to it
> using the wicket API.
If it's very simple, a straight get("path") may be OK, but
generally it's better to use visitors and/or findParent to
not depend so much on the exact component hierarchy.
> public AdminPage() {
> add(new Label("message", "If you see this message wicket is properly
> configured and running"));
class StatusMessage extends Label {
public StatusMessage() {
super("message", "If you see this message wicket is
properly configured and running");
}
}
> @Override
> public void onSubmit()
> {
> Label lbl = new Label("message", "Deleted");
> this.get("message").replaceWith(lbl);
getPage().visitChildren(StatusMessage.class, new
IVisitor<Component>() {
public Object component(Component component) {
component.setDefaultModelObject("Deleted");
}
});
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]