Comments inlined ...
Howard Lewis Ship wrote:
<t:comp type="If" test="loggedIn">
Welcome to the show, ${userName}!
</t:comp><t:comp type="Else" >
Click <a t:type="ActionLink" t:id="login">here</a> to log in.
</t:comp>
This is how its done in Tapestry 4. I have issues with this. First,
its not possible to bind the Else except to the most recently rendered
If. In Java, you have grouping constructs ("{" and "}") to make sure
your desires are unambiguous.
The obvious difference here is that in Java you don't do this:
if (condition)
{
a = b;
}
someMethod(); // must be done now!
else
{
c = d;
}
Although this is quite doable ... it's a matter of storing somewhere
the status of the most recent If evaluation so that the Else component
can read it. that's not difficult, it would be an Environmental
service, its still just feels wrong to me.
Jesse's example looks better when you need to add interceding content.
The nesting of the else parameter impedes a common use case for else,
and if there's no Else component, we end up 'negatively' violating DRY:
<t:comp type="If" test="loggedIn">
Welcome to the show, ${userName}!
</t:comp>
<commoncontent> ... </commoncontent>
<t:comp type="If" test="!loggedIn">
Click <a t:type="ActionLink" t:id="login">here</a> to log in.
</t:comp>
Cheers,
Nick.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]