Excellent tips Thiago, cheers.


-----Original Message-----
From: Thiago H. de Paula Figueiredo <thiag...@gmail.com>
Reply-to: "Tapestry users" <users@tapestry.apache.org>
To: Tapestry users <users@tapestry.apache.org>
Subject: Re: a simple <t:if> question
Date: Thu, 11 Nov 2010 09:52:01 -0200

On Thu, 11 Nov 2010 08:15:33 -0200, Richard Hill <r...@su3analytics.com>  
wrote:

> In T5, 5.1 you can do something like this. In .tml:
> <t:if test="showTitle">
>   <span>${reportTitle}</span>
>   ...
>   <t:parameter name="else">
>     <span>No report to display</span>
>   </t:parameter>
> </t:if>
> I believe the "else" syntax may have changed in T5.2.

There are now two syntaxes for passing values to parameters that are  
blocks: <t:parameter name="xxx"> (Tapetry 5.0+) and <p:xxx> (Tapestry  
5.1+).

I like to write if/else's this way:

<t:if test="showTitle">
   <span>${reportTitle}</span>
</t:if>
<t:if test="!showTitle">
   <span>No report to display</span>
</t:if>

Better yet, using invisible instrumentation (I love my templates to look  
like HTML):

<span t:type="If" t:test="showTitle">${reportTitle}</span>
<span t:type="If" t:test="!showTitle">No report to display</span>

Still better yet, moving all the logic to the class, as there's always a  
<span>:

public boolean getReportTitle() {
    return reportId > 0 ? reportTitle : "No report to display";
}

<span>${reportTitle}</span>

:)




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

Reply via email to