Another way is to pass down a common IModel<String> into both panels
from a shared parent. Or to create an abstract readonly model on the
label that will get the model object from the text field.
e.g.
Shared model from above.
In Parent Component:
IModel<String>fieldModel = new Model<String();
add (autocompletePanel = new AutoCompletPanel("textfield", fieldModel));
add (new Label ("label", fieldModel);
e.g. custom model on the label:
In Parent Component:
add (autocompletePanel = new AutoCompletPanel("textfield"...));
add (new Label ("label", new AbstractReadOnlyModel <String>() {
public String getObject() {
return autocompletePanel.getModelObjectAsString();
}
});
If they aren't contained in this way you can have the field model
actually store the value in the session or a session scoped service bean
and then have the label model fetch from that source instead.
Regards,
Mike
You just use a normal reference if you can. Or, use a more
"listenery" approach.
On Wed, Apr 13, 2011 at 7:19 PM, Reinout van Schouwen<[email protected]> wrote:
Hello all,
This would seem like a simple question but I've been tearing my hair
out all evening about it.
I have one form component, a wiquery autocomplete textfield.Once the
user has entered a value in it I want the value to appear in a label
in a different panel.
My approach was to use an AjaxFormComponentUpdatingBehavior, to update
the model of the label once a value has been entered and adding the
label's container to the AjaxRequestTarget. But how do I refer to the
label? I tried to use getPage().get(labelId) but this gives me a null
pointer.
Surely I'm overlooking a simple solution that Google didn't turn up for me?
regards,
--
Reinout van Schouwen
http://vanschouwen.info/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]