You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Piero Sartini <li...@pierosartini.de> on 2009/06/29 15:24:35 UTC

Property access in var: binded objects?

Iterating over objects with loop and var: can be handy. But I discovered (and 
it is mentioned in the docs) that it is not possible to access the properties 
of these objects.

Why is this? Is it too complicated to support? (I can't see at which point it 
is so different to "normal" property expressions.

What I want to do is s.th. like this:

<t:loop source="userlist" value="var:user">
${var:user.username}
</t:loop>

It would allow me from getting rid of all these @Property private User user; 
things that needs to be there only to support the rendering.

	Piero

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Property access in var: binded objects?

Posted by Howard Lewis Ship <hl...@gmail.com>.
On Mon, Jun 29, 2009 at 4:47 PM, Piero Sartini <li...@pierosartini.de>wrote:

> > Is @Property so hard or awful?
>
> No, it isn't. But for me these kind of objects have temporary character. I
> really don't like them to pollute my page classes.


And to me, that's exactly what page classes are for.


>
>
> Maybe its just me, but if I need a property just to iterate over a list it
> feels like it could be optimized.... tapestry is reducing needed code
> whereever possible. In this particular case I think its hard to understand
> why
> it breaks with this rule. Especially because var: is available and iterates
> over the object fine: callit .toString() method if displayed.
>
> But accessing the properties of an object that is there fails... its just
> something I would not have expected.
>
>        Piero
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos

Re: Property access in var: binded objects?

Posted by Piero Sartini <li...@pierosartini.de>.
> Is @Property so hard or awful?

No, it isn't. But for me these kind of objects have temporary character. I 
really don't like them to pollute my page classes.

Maybe its just me, but if I need a property just to iterate over a list it 
feels like it could be optimized.... tapestry is reducing needed code 
whereever possible. In this particular case I think its hard to understand why 
it breaks with this rule. Especially because var: is available and iterates 
over the object fine: callit .toString() method if displayed. 

But accessing the properties of an object that is there fails... its just 
something I would not have expected.

	Piero


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Property access in var: binded objects?

Posted by Howard Lewis Ship <hl...@gmail.com>.
Is @Property so hard or awful?

On Mon, Jun 29, 2009 at 6:35 AM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> Quick answer: Tapestry can't statically figure out the type of the
> variable, so it can't use the prop binding (which uses on-the-fly
> class creation, not reflection) on it. Anyway, you can add your own
> binding to do what you want. Just use the RenderVariableBinding and
> RenderVariableBindingFactory as examples. ;)
>
> --
> Thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos

Re: Property access in var: binded objects?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Quick answer: Tapestry can't statically figure out the type of the
variable, so it can't use the prop binding (which uses on-the-fly
class creation, not reflection) on it. Anyway, you can add your own
binding to do what you want. Just use the RenderVariableBinding and
RenderVariableBindingFactory as examples. ;)

-- 
Thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org