You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Vjeran Marcinko <vj...@tis.hr> on 2004/04/30 17:58:08 UTC

Trick for NOT rendering some html tag ?

Hi.

Developing web applications, in various frameworks, I came to one problem,
although simple, always makes little mess in template...
For example, let's say you want to print bold some text depending upon some
condition. If condition is not met, than I would like to be printed
normally. Straitforward way is:

<span jwcid="@Conditional" condition="ognl:someCondition">
    <b>
        Stuff to be printed ....
    </b>
</span>
<span jwcid="@Conditional" condition="ognl:!someCondition">
        Stuff to be printed ....
</span>

So we have a lot of duplicated html stuff just because this simple
requirement. Especially when this wrapped stuff to be printed is really
long.
Is there maybe some easier way to acomplish this task... Looking at
Tapestry, I wouldn't say so, but maybe someone has found some neat trick
that would be like :
<b jwcid="@SomeComponent" element="b" condition="ognl:someCondition">
</b>
thus <b> tag would be rendered only if condition is met, otherwise nothing
would be rendered ?

-Vjeran


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


Re: Trick for NOT rendering some html tag ?

Posted by Eric Schneider <er...@centralparksoftware.com>.
Vjeran,

I think you could certainly simplify this with the use of style sheets and
the "Any" component.  Something like:

<span jwcid="@Any" class="ognl:myStyle" element="span">
    Stuff to be printed ....
</span>

.java:

public String getMyStyle() {
    return (getSomeCondition())? "boldText": "regularText";
}

Hope that helps.
Eric


----- Original Message ----- 
From: "Vjeran Marcinko" <vj...@tis.hr>
To: <ta...@jakarta.apache.org>
Sent: Friday, April 30, 2004 11:58 AM
Subject: Trick for NOT rendering some html tag ?


> Hi.
>
> Developing web applications, in various frameworks, I came to one problem,
> although simple, always makes little mess in template...
> For example, let's say you want to print bold some text depending upon
some
> condition. If condition is not met, than I would like to be printed
> normally. Straitforward way is:
>
> <span jwcid="@Conditional" condition="ognl:someCondition">
>     <b>
>         Stuff to be printed ....
>     </b>
> </span>
> <span jwcid="@Conditional" condition="ognl:!someCondition">
>         Stuff to be printed ....
> </span>
>
> So we have a lot of duplicated html stuff just because this simple
> requirement. Especially when this wrapped stuff to be printed is really
> long.
> Is there maybe some easier way to acomplish this task... Looking at
> Tapestry, I wouldn't say so, but maybe someone has found some neat trick
> that would be like :
> <b jwcid="@SomeComponent" element="b" condition="ognl:someCondition">
> </b>
> thus <b> tag would be rendered only if condition is met, otherwise nothing
> would be rendered ?
>
> -Vjeran
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


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


Re: Trick for NOT rendering some html tag ?

Posted by Paul Ferraro <pm...@columbia.edu>.
A quick fix could be as simple as this:

<span jwcid="@Any" element="ognl:someCondition ? 'b' : 'span'">
    Stuff to be printed ...
</span>

Paul Ferraro

Vjeran Marcinko wrote:

>Hi.
>
>Developing web applications, in various frameworks, I came to one problem,
>although simple, always makes little mess in template...
>For example, let's say you want to print bold some text depending upon some
>condition. If condition is not met, than I would like to be printed
>normally. Straitforward way is:
>
><span jwcid="@Conditional" condition="ognl:someCondition">
>    <b>
>        Stuff to be printed ....
>    </b>
></span>
><span jwcid="@Conditional" condition="ognl:!someCondition">
>        Stuff to be printed ....
></span>
>
>So we have a lot of duplicated html stuff just because this simple
>requirement. Especially when this wrapped stuff to be printed is really
>long.
>Is there maybe some easier way to acomplish this task... Looking at
>Tapestry, I wouldn't say so, but maybe someone has found some neat trick
>that would be like :
><b jwcid="@SomeComponent" element="b" condition="ognl:someCondition">
></b>
>thus <b> tag would be rendered only if condition is met, otherwise nothing
>would be rendered ?
>
>-Vjeran
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


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