You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eddie Bush <ek...@swbell.net> on 2002/04/30 21:28:04 UTC

Advanced Tag Usage

Hello Guys/Gals - I'm in a bit of a spot.

I tend to try to use tags for everything I can, as I really dislike having scriplets in my JSP pages.  However, I'm writing a tile that needs to use tags to specify attribute values for other tags - and I can't seem to manage to make it work.

What I've tried is:

<html:link href='<bean:write name="url"/>' styleClass='<bean:write name="linkStyle"/>'><bean:write name='text'/></html:link>

<html:link href="<bean:write name='url'/>" styleClass="<bean:write name='linkStyle'/>"><bean:write name='text'/></html:link>

Neither of those two seem to acheive the desired end result.  Is there a way to do this without defiling my JSP page with scriplets?  Any pointers would be most welcome and appreciated.

Are scriplets my only bullet to shoot this problem down?

Thanks so much!

Eddie



Re: Advanced Tag Usage

Posted by Eddie Bush <ek...@swbell.net>.
Well, if I must I must.  =/

Thanks Craig!

----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, April 30, 2002 3:00 PM
Subject: Re: Advanced Tag Usage


>
>
> On Tue, 30 Apr 2002, Eddie Bush wrote:
>
> > Date: Tue, 30 Apr 2002 14:28:04 -0500
> > From: Eddie Bush <ek...@swbell.net>
> > Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> > To: Struts Users Mailing List <st...@jakarta.apache.org>
> > Subject: Advanced Tag Usage
> >
> > Hello Guys/Gals - I'm in a bit of a spot.
> >
> > I tend to try to use tags for everything I can, as I really dislike
having scriplets in my JSP pages.  However, I'm writing a tile that needs to
use tags to specify attribute values for other tags - and I can't seem to
manage to make it work.
> >
> > What I've tried is:
> >
> > <html:link href='<bean:write name="url"/>' styleClass='<bean:write
> > name="linkStyle"/>'><bean:write name='text'/></html:link>
> >
> > <html:link href="<bean:write name='url'/>" styleClass="<bean:write
> > name='linkStyle'/>"><bean:write name='text'/></html:link>
> >
> > Neither of those two seem to acheive the desired end result.
>
> That is because this is not legal XML syntax, and is therefore not legal
> JSP syntax.
>
> >  Is there a
> > way to do this without defiling my JSP page with scriplets?  Any
> > pointers would be most welcome and appreciated.
> >
> > Are scriplets my only bullet to shoot this problem down?
> >
>
> You can accomplish what you want with runtime expressions:
>
>   <html:link href='<%= request.getAttribute("url") >%' .../>
>
> which are not, IMHO, particularly evil when used for this purpose.
>
> In JSP 1.3, there will be an ability to use the expression language that
> is currently a part of JSTL everywhere in a page -- in attribute values
> like this, plus in template text.  Then, you'll be able to write:
>
>   <html:link href="${url}" styleClass="${linkStyle}">${text}</html:link>
>
> for this expression -- but that won't be available for a while.  In the
> mean time, runtime expressions are ok.
>
> > Thanks so much!
> >
> > Eddie
> >
>
> Craig
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Advanced Tag Usage

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 30 Apr 2002, Eddie Bush wrote:

> Date: Tue, 30 Apr 2002 14:28:04 -0500
> From: Eddie Bush <ek...@swbell.net>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Advanced Tag Usage
>
> Hello Guys/Gals - I'm in a bit of a spot.
>
> I tend to try to use tags for everything I can, as I really dislike having scriplets in my JSP pages.  However, I'm writing a tile that needs to use tags to specify attribute values for other tags - and I can't seem to manage to make it work.
>
> What I've tried is:
>
> <html:link href='<bean:write name="url"/>' styleClass='<bean:write
> name="linkStyle"/>'><bean:write name='text'/></html:link>
>
> <html:link href="<bean:write name='url'/>" styleClass="<bean:write
> name='linkStyle'/>"><bean:write name='text'/></html:link>
>
> Neither of those two seem to acheive the desired end result.

That is because this is not legal XML syntax, and is therefore not legal
JSP syntax.

>  Is there a
> way to do this without defiling my JSP page with scriplets?  Any
> pointers would be most welcome and appreciated.
>
> Are scriplets my only bullet to shoot this problem down?
>

You can accomplish what you want with runtime expressions:

  <html:link href='<%= request.getAttribute("url") >%' .../>

which are not, IMHO, particularly evil when used for this purpose.

In JSP 1.3, there will be an ability to use the expression language that
is currently a part of JSTL everywhere in a page -- in attribute values
like this, plus in template text.  Then, you'll be able to write:

  <html:link href="${url}" styleClass="${linkStyle}">${text}</html:link>

for this expression -- but that won't be available for a while.  In the
mean time, runtime expressions are ok.

> Thanks so much!
>
> Eddie
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>