You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2010/08/05 12:26:54 UTC
t5: if and expression
Hi,
is it possible to use an expression in the t:if? something like this
< t:if test="user.id=99">
< /t:if>
?
--
View this message in context: http://old.nabble.com/t5%3A-if-and-expression-tp29355495p29355495.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: t5: if and expression
Posted by Steve Eynon <st...@alienfactory.co.uk>.
Nope, you can't... T4 used OGNL where you could, but T5 is pretty much
just calls bean properties. See here:
http://tapestry.apache.org/tapestry5.2-dev/guide/propexp.html
But this is a good thing, for it stops you from putting logic and
programming in your template.
So what you can do is:
< t:if test="user.hasIdOf(99)">
and have a method on User:
public boolean IsHasIsOf(int is) {
return this.id == id;
}
If you don't like polluting your entities with T5 methods (esp if
they're only used the once) then you could stick them on your page /
component class where they're used.
Steve.
--
Steve Eynon
On 5 August 2010 11:26, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi,
> is it possible to use an expression in the t:if? something like this
>
> < t:if test="user.id=99">
> < /t:if>
>
> ?
> --
> View this message in context: http://old.nabble.com/t5%3A-if-and-expression-tp29355495p29355495.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: t5: if and expression
Posted by based2 <ba...@free.fr>.
http://old.nabble.com/T5%3A-using-an-expression-in-t%3Aif-ts21931606.html#a21931606
http://old.nabble.com/T5%3A-Using-expression-language-in-If-component-ts16561976.html#a16561976
Angelo Chen wrote:
>
> Hi,
> is it possible to use an expression in the t:if? something like this
>
> < t:if test="user.id=99">
> < /t:if>
>
> ?
>
--
View this message in context: http://old.nabble.com/t5%3A-if-and-expression-tp29355495p29356375.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: t5: if and expression
Posted by Howard Lewis Ship <hl...@gmail.com>.
In Tapestry 4, OGNL had to do a lot of heavy lifting, since you didn't have
reloadable Java classes; thus I've seen lots of very complicated OGNL
expressions mixed into T4 templates. That causes its own problems in terms
of maintainability and brittleness in the face of refactoring.
Simply comparisons (==, !=, lt, gt, lteq, gteq) may make it into a future T5
but as of now I'd just code this as:
<t:if test="showCustomerData"> ... </t:if>
and
public boolean getShowCustomerData() { return customer.getId() == 99; }
... and there you have a more readable template, where instead of an opaque
expression, you have a mnemonic name.
On Fri, Aug 6, 2010 at 4:27 AM, Steve Eynon
<st...@alienfactory.co.uk>wrote:
> Yeah, I keep forgetting about the non-null binding to a boolean true
> (see Notes section in the IF component docs) - a really cool idea!
> --
> Steve Eynon
>
>
>
> On 5 August 2010 18:33, based2 <ba...@free.fr> wrote:
> >
> >
> http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/If.html
> >
> >
> > Angelo Chen wrote:
> >>
> >> Hi,
> >> is it possible to use an expression in the t:if? something like this
> >>
> >> < t:if test="user.id=99">
> >> < /t:if>
> >>
> >> ?
> >>
>
> ---------------------------------------------------------------------
> 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
The source for Tapestry training, mentoring and support. Contact me to learn
how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com
Re: t5: if and expression
Posted by Steve Eynon <st...@alienfactory.co.uk>.
Yeah, I keep forgetting about the non-null binding to a boolean true
(see Notes section in the IF component docs) - a really cool idea!
--
Steve Eynon
On 5 August 2010 18:33, based2 <ba...@free.fr> wrote:
>
> http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/If.html
>
>
> Angelo Chen wrote:
>>
>> Hi,
>> is it possible to use an expression in the t:if? something like this
>>
>> < t:if test="user.id=99">
>> < /t:if>
>>
>> ?
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: t5: if and expression
Posted by based2 <ba...@free.fr>.
http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/If.html
Angelo Chen wrote:
>
> Hi,
> is it possible to use an expression in the t:if? something like this
>
> < t:if test="user.id=99">
> < /t:if>
>
> ?
>
--
View this message in context: http://old.nabble.com/t5%3A-if-and-expression-tp29355495p29356374.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org