You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by La...@ubs.com on 2007/07/03 07:20:10 UTC

Nested tag in attribute value

Hi all,

First of all, if this query has already been solved earlier, please
ignore below question and simply point me to the solution.

In one of my projects am using Struts framework along with Hibernate.
While Struts provides many tag libs like bean, html and logic I still
felt need to create my own tags to avoid the code repetition and
generalize the coding style. In the course of creating custom tags, I
came across one issue as follows...

How can I pass other tags runtime values to the attributes of my custom
tags like this..

<mt:clink url="/categoryEvent.do?event=edit&id=<bean:write
name="category" property="id"/>">Edit</mt:clink>

In this case it gives me error : org.apache.jasper.JasperException:
/bo/category/categoryList.jsp(36,78) equal symbol expected 
though I have already set the runtime expression value to true in tag
lib as follows..
		<attribute>
			<name>url</name>
			<required>true</required>
			<rtexprvalue>true</rtexprvalue>
  		</attribute>
And getting this value in doStartTag method in tag handler class.
	
Actually I am creating one custom tag that will automatically add
context path to the given url so that my app works on any context path.
I am using JSP version 1.1 in my taglib.

Any help or suggestion to do this in better way?

Thanks, 
Lalit 




Re: Nested tag in attribute value

Posted by Kris Schneider <kr...@dotech.com>.
Quoting Eric Haszlakiewicz <er...@swapsimple.com>:

> On Tue, Jul 03, 2007 at 09:59:59AM -0400, Kris Schneider wrote:
> > As you've discovered, embedding one tag in the attribute value of another
> tag is
> > "illegal" - even if you had gotten the quotes right ;-). You would need to
> do
> > something like:
> > 
> > <bean:define id="categoryId" name="category" property="id"/>
> > <mt:clink url='<%= "/categoryEvent.do?event=edit&id=" + id
> %>'>Edit</mt:clink>
> > 
> > I think. It's been awhile since I've been down that road...
> 
> In a more general sense, you can capture the output of anything with the 
> c:set tag:
> 
> <c:set var="somevar">lalala<my:tag/> <other:tag/> etc... </c:set>
> 
> And then just use ${somevar} whereever you need the value.  (no need for
> scriptlets either)

The original post states JSP 1.1. Even JSTL 1.0 requires JSP 1.2.

> eric

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Re: Nested tag in attribute value

Posted by Eric Haszlakiewicz <er...@swapsimple.com>.
On Tue, Jul 03, 2007 at 09:59:59AM -0400, Kris Schneider wrote:
> As you've discovered, embedding one tag in the attribute value of another tag is
> "illegal" - even if you had gotten the quotes right ;-). You would need to do
> something like:
> 
> <bean:define id="categoryId" name="category" property="id"/>
> <mt:clink url='<%= "/categoryEvent.do?event=edit&id=" + id %>'>Edit</mt:clink>
> 
> I think. It's been awhile since I've been down that road...

In a more general sense, you can capture the output of anything with the 
c:set tag:

<c:set var="somevar">lalala<my:tag/> <other:tag/> etc... </c:set>

And then just use ${somevar} whereever you need the value.  (no need for
scriptlets either)

eric

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


Re: Nested tag in attribute value

Posted by Kris Schneider <kr...@dotech.com>.
As you've discovered, embedding one tag in the attribute value of another tag is
"illegal" - even if you had gotten the quotes right ;-). You would need to do
something like:

<bean:define id="categoryId" name="category" property="id"/>
<mt:clink url='<%= "/categoryEvent.do?event=edit&id=" + id %>'>Edit</mt:clink>

I think. It's been awhile since I've been down that road...

Quoting Lalit.Kumar@ubs.com:

> Hi all,
> 
> First of all, if this query has already been solved earlier, please
> ignore below question and simply point me to the solution.
> 
> In one of my projects am using Struts framework along with Hibernate.
> While Struts provides many tag libs like bean, html and logic I still
> felt need to create my own tags to avoid the code repetition and
> generalize the coding style. In the course of creating custom tags, I
> came across one issue as follows...
> 
> How can I pass other tags runtime values to the attributes of my custom
> tags like this..
> 
> <mt:clink url="/categoryEvent.do?event=edit&id=<bean:write
> name="category" property="id"/>">Edit</mt:clink>
> 
> In this case it gives me error : org.apache.jasper.JasperException:
> /bo/category/categoryList.jsp(36,78) equal symbol expected 
> though I have already set the runtime expression value to true in tag
> lib as follows..
> 		<attribute>
> 			<name>url</name>
> 			<required>true</required>
> 			<rtexprvalue>true</rtexprvalue>
>   		</attribute>
> And getting this value in doStartTag method in tag handler class.
> 	
> Actually I am creating one custom tag that will automatically add
> context path to the given url so that my app works on any context path.
> I am using JSP version 1.1 in my taglib.
> 
> Any help or suggestion to do this in better way?
> 
> Thanks, 
> Lalit 

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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