tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davor Hrg (JIRA)" <...@tapestry.apache.org>
Subject [jira] Created: (TAPESTRY-2269) improve if component to support block when test is true
Date Mon, 17 Mar 2008 13:05:24 GMT
improve if component to support block when test is true
-------------------------------------------------------

                 Key: TAPESTRY-2269
                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2269
             Project: Tapestry
          Issue Type: Improvement
            Reporter: Davor Hrg
            Priority: Minor
             Fix For: 5.0.12


This addition can make if component more versatile:


I came up with this while trying to make the template code more readable.

The first version was some ifs and loops which I decided to break up into blocks,
so that logic inside the loop is more readable.

so one snippet stuck to me as it can be done better...
the first version was:

<t:if test="currentContainer"><t:delegate to="containerEditor"/></t:if>
<t:unless test="currentContainer"><t:delegate to="block:containerDisplay"/></t:unless>

version 2.
<t:if test="currentContainer" else="block:containerDisplay"><t:delegate to="containerEditor"/></t:if>

this is scrambled and akward so I've made a copy of if component and got this:
<t:if test="currentContainer" render="containerEditor" else="block:containerDisplay"/>

with "render" block parameter the if component in this case becomes simpler to read
and can also act as conditional delegate when "else" block parameter is ommited:
<t:if test="currentContainer" render="containerEditor" else="block:containerDisplay"/>


this also simply doable by pushing more logic to java code:
<t:delegate to="containerRender"/>

public Object getContainerRender(){
    if(isCurrentContainer){
        return _containerEditor;
    }else{
        return _resources.getBlock("containerDisplay");
    }
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message