Property access in var: binded objects?

View: New views
5 Messages — Rating Filter:   Alert me  

Property access in var: binded objects?

by Piero Sartini-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
For additional commands, e-mail: users-help@...


Re: Property access in var: binded objects?

by Thiago H. de Paula Figueiredo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
For additional commands, e-mail: users-help@...


Re: Property access in var: binded objects?

by Howard Lewis Ship :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is @Property so hard or awful?

On Mon, Jun 29, 2009 at 6:35 AM, Thiago H. de Paula Figueiredo <
thiagohp@...> 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@...
> For additional commands, e-mail: users-help@...
>
>


--
Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos

Re: Property access in var: binded objects?

by Piero Sartini-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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@...
For additional commands, e-mail: users-help@...


Re: Property access in var: binded objects?

by Howard Lewis Ship :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jun 29, 2009 at 4:47 PM, Piero Sartini <lists@...>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@...
> For additional commands, e-mail: users-help@...
>
>


--
Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos