You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "wmike1987@gmail.com" <wm...@gmail.com> on 2011/07/20 19:38:14 UTC
property model question
In the wicket example of Form Input (
http://wicketstuff.org/wicket14/forminput/
http://wicketstuff.org/wicket14/forminput/ ), I'm looking at the source and
can't make out what's happening with this line:
// display the multiply result
Label multiplyLabel = new Label("multiplyLabel", new
PropertyModel<Integer>(
getDefaultModel(), "multiply"));
I understand what this accomplishes, but I don't understand how. We're
passing this property model the default model of what exactly? I don't get
what it means to pass a property model a sublass of IModel to base itself
off of.
Thanks,
mike
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/property-model-question-tp3681616p3681616.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: property model question
Posted by Igor Vaynberg <ig...@gmail.com>.
this is called model chaining. where models know that their model
object is another model and can properly handle it.
in this particular example
imodel d=getdefaultmodel()
imodel p=new propertymodel(d, "multiply")
p.getobject() then does this
object target=mytarget; (in this case d)
while (target instanceof imodel) { target=imodel.getobject(); }
getproperty(target, property);
so in execution p.getobject() resolves to this: d.getobject().getmultiply();
makes sense?
-igor
On Wed, Jul 20, 2011 at 10:38 AM, wmike1987@gmail.com
<wm...@gmail.com> wrote:
> In the wicket example of Form Input (
> http://wicketstuff.org/wicket14/forminput/
> http://wicketstuff.org/wicket14/forminput/ ), I'm looking at the source and
> can't make out what's happening with this line:
>
> // display the multiply result
> Label multiplyLabel = new Label("multiplyLabel", new
> PropertyModel<Integer>(
> getDefaultModel(), "multiply"));
>
> I understand what this accomplishes, but I don't understand how. We're
> passing this property model the default model of what exactly? I don't get
> what it means to pass a property model a sublass of IModel to base itself
> off of.
>
> Thanks,
> mike
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/property-model-question-tp3681616p3681616.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: property model question
Posted by Per Newgro <pe...@gmx.ch>.
Am 20.07.2011 19:38, schrieb wmike1987@gmail.com:
> In the wicket example of Form Input (
> http://wicketstuff.org/wicket14/forminput/
> http://wicketstuff.org/wicket14/forminput/ ), I'm looking at the source and
> can't make out what's happening with this line:
>
> // display the multiply result
> Label multiplyLabel = new Label("multiplyLabel", new
> PropertyModel<Integer>(
> getDefaultModel(), "multiply"));
>
> I understand what this accomplishes, but I don't understand how. We're
> passing this property model the default model of what exactly? I don't get
> what it means to pass a property model a sublass of IModel to base itself
> off of.
>
> Thanks,
> mike
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/property-model-question-tp3681616p3681616.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
The property model is set formerly to the parent container (form or
panel) by constructor injection.
new Form("id", defaultModel);
or
new Panel("id", defaultModel);
If you check the hierachy of parent classes you can see the
getDefaultModel mthod implementation.
Cheers
Per
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org