You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by rahul <ra...@amsoft.net> on 2005/09/24 10:05:40 UTC
tag within tag
Hi all,
Can anyone tell me how to use <bean:write> tag inside <html:href>
I tried it like:
<logic:iterate id="element" name="myBeanList">
<html:link href="/someAction.do?id=<bean:write name='element'
property='id>" >
<bean:write name="element" property="idDescription" />
</html:link>
</logic:iterate>
but its not working, it is generating the following html
<a href="http://localhost:8080/someAction.do?id=<bean:write name='element'
property='id'>">My Desc </a>
what's the correct way of doing this?
--RahulJoshi
Re: tag within tag
Posted by Laurie Harper <la...@holoweb.net>.
You can't nest a custom tag in an attribute of another custom tag. It's
illegal JSP syntax. You have (at least) a couple of options, depending
on what level of the servlet spec you're using:
<html:link>
<jsp:attribute name="href">
<bean:write name='element' property='id'/>
</jsp:attribute>
</html:link>
should work everywhere. An alternative if you have JSTL available:
<bean:define id="href" name='element' property='id'/>
<html:link href="${href}" ...
And if not:
<bean:define id="href" name='element' property='id'/>
<html:link href="<%= href %>" ...
L.
rahul wrote:
> thanks for the help
> see inline comments ####
>
>
>>-----Original Message-----
>>From: Sławek Tuleja [mailto:tusla@wp.pl]
>>Sent: Saturday, September 24, 2005 1:57 PM
>>To: Struts Users Mailing List
>>Subject: Re: <bean:write> tag within <html:link> tag
>>
>>
>>rahul wrote:
>>
>>
>>>Hi all,
>>>
>>>Can anyone tell me how to use <bean:write> tag inside <html:href>
>>>I tried it like:
>>>
>>> <logic:iterate id="element" name="myBeanList">
>>>
>>> <html:link href="/someAction.do?id=<bean:write name='element'
>>>property='id>" >
>>> <bean:write name="element" property="idDescription" />
>>>
>>> </html:link>
>>>
>>> </logic:iterate>
>>>
>>>but its not working, it is generating the following html
>>>
>>><a href="http://localhost:8080/someAction.do?id=<bean:write
>>
>>name='element'
>>
>>>property='id'>">My Desc </a>
>>>
>>>what's the correct way of doing this?
>>>
>>>
>>>
>>>--RahulJoshi
>>>
>>>
>>>
>>>
>>>__________ NOD32 1.1212 (20050908) Information __________
>>>
>>>This message was checked by NOD32 antivirus system.
>>>http://www.nod32.com
>>>
>>>
>>>
>>
>>Hi Rahul
>>you forgot about /> after property="id"
>
>
> #### sorry for that
>
>
>>try this:
>>
>><html:link href="/someAction.do?id=<bean:write name='element'
>>property='id' />" ><bean:write name="element"
>>property="idDescription" /></html:link>
>>
>>or
>>
>><a href="/someAction.do?id=<bean:write name="element"
>>property="id" />"><bean:write name="element"
>>property="idDescription" /></a>
>
>
> ##### second one works perfectly (though I need to remove / from href value)
> but first one, (<html:link>) is still not working
> any idea?
>
>
>
>
>>
>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: tag within tag
Posted by rahul <ra...@amsoft.net>.
thanks for the help
see inline comments ####
> -----Original Message-----
> From: Sławek Tuleja [mailto:tusla@wp.pl]
> Sent: Saturday, September 24, 2005 1:57 PM
> To: Struts Users Mailing List
> Subject: Re: <bean:write> tag within <html:link> tag
>
>
> rahul wrote:
>
> >Hi all,
> >
> >Can anyone tell me how to use <bean:write> tag inside <html:href>
> >I tried it like:
> >
> > <logic:iterate id="element" name="myBeanList">
> >
> > <html:link href="/someAction.do?id=<bean:write name='element'
> >property='id>" >
> > <bean:write name="element" property="idDescription" />
> >
> > </html:link>
> >
> > </logic:iterate>
> >
> >but its not working, it is generating the following html
> >
> ><a href="http://localhost:8080/someAction.do?id=<bean:write
> name='element'
> >property='id'>">My Desc </a>
> >
> >what's the correct way of doing this?
> >
> >
> >
> >--RahulJoshi
> >
> >
> >
> >
> >__________ NOD32 1.1212 (20050908) Information __________
> >
> >This message was checked by NOD32 antivirus system.
> >http://www.nod32.com
> >
> >
> >
> Hi Rahul
> you forgot about /> after property="id"
#### sorry for that
> try this:
>
> <html:link href="/someAction.do?id=<bean:write name='element'
> property='id' />" ><bean:write name="element"
> property="idDescription" /></html:link>
>
> or
>
> <a href="/someAction.do?id=<bean:write name="element"
> property="id" />"><bean:write name="element"
> property="idDescription" /></a>
##### second one works perfectly (though I need to remove / from href value)
but first one, (<html:link>) is still not working
any idea?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: tag within tag
Posted by Sławek Tuleja <tu...@wp.pl>.
rahul wrote:
>Hi all,
>
>Can anyone tell me how to use <bean:write> tag inside <html:href>
>I tried it like:
>
> <logic:iterate id="element" name="myBeanList">
>
> <html:link href="/someAction.do?id=<bean:write name='element'
>property='id>" >
> <bean:write name="element" property="idDescription" />
>
> </html:link>
>
> </logic:iterate>
>
>but its not working, it is generating the following html
>
><a href="http://localhost:8080/someAction.do?id=<bean:write name='element'
>property='id'>">My Desc </a>
>
>what's the correct way of doing this?
>
>
>
>--RahulJoshi
>
>
>
>
>__________ NOD32 1.1212 (20050908) Information __________
>
>This message was checked by NOD32 antivirus system.
>http://www.nod32.com
>
>
>
Hi Rahul
you forgot about /> after property="id"
try this:
<html:link href="/someAction.do?id=<bean:write name='element' property='id' />" ><bean:write name="element" property="idDescription" /></html:link>
or
<a href="/someAction.do?id=<bean:write name="element" property="id" />"><bean:write name="element" property="idDescription" /></a>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: tag within tag
Posted by Catherine <ma...@roomity.com>.
Myself have a similar problem to solve.
<html:submit onclick="setSubmitAction(<bean:message key="MyPanel.theField.label"/>)"><bean:message key="MyPanel.theField.label"/></htm:submit>
It is no problem for the second <bean:message> tag to get evaluated. But it seems that nothing will get evaluated as the parameter of the JavaScript function. As Larry pointed out earlier, it is illegal to put tag inside another tag. Then how do I pass the value from the resource bundle?
Thanks,
Catherine
-------------------------------------------------------------
<a href="http://Struts_User_List.roomity.com">roomity.com</a>
roomity.com is broadband internet. ~~1127773200734~~
-------------------------------------------------------------
Re: tag within tag
Posted by Laurie Harper <la...@holoweb.net>.
Catherine wrote:
> Try this. It's simpler.
>
> <html:link action="someAction" paramName="element" paramProperty="id" paramId="id">
It may be simpler, but it doesn't do the same thing... That would result
in <a href="/myapp/someAction.do?id=/foo"/> instead of <a href="/foo"/>.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: tag within tag
Posted by Catherine <ma...@roomity.com>.
Hi,
Try this. It's simpler.
<html:link action="someAction" paramName="element" paramProperty="id" paramId="id">
Catherine
-------------------------------------------------------------
<a href="http://Struts_User_List.roomity.com">roomity.com</a>
roomity.com is broadband internet. ~~1127770884754~~
-------------------------------------------------------------
Re: tag within tag
Posted by Laurie Harper <la...@holoweb.net>.
Catherine wrote:
> I thought rahul wanted <a href="/myapp/someAction.do?id=/foo"/> to invoke someAction and passing a parameter, id. What will happen if you click <a hred="/foo"/>?
Exactly what you'd expect: the browser with load the resource at /foo.
> I still can't figure out how to solve my problem, that is get <bean:message> tag evaluated as the parameter of a javascript call. Like the following:
>
> <html:submit onclick="setSubmitAction(<bean:message key="MyPanel.theField.label"/>)"><bean:message key="MyPanel.theField.label"/></htm:submit>
As pointed out at the beginning of this thread, you can't nest JSP tags
like that. You can use the same approachs to solve your problem as I
described for Rahul.
> Some time I also need to pass a java variable as the parameter to a javascript function, and I encounter the same problem. For example,
> <html:submit onclick="setSubmitAction(<%= myVar %>)" >
> myVar will not get evaluated.
This, on the other hand, should work fine. Make sure tha myVar is
correctly defined first. You could check that by putting <%
System.out.println("myVar = " + myVar); %> immediately before the
<html:sumbit> tag.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: tag within tag
Posted by Catherine <ma...@roomity.com>.
I thought rahul wanted <a href="/myapp/someAction.do?id=/foo"/> to invoke someAction and passing a parameter, id. What will happen if you click <a hred="/foo"/>?
I still can't figure out how to solve my problem, that is get <bean:message> tag evaluated as the parameter of a javascript call. Like the following:
<html:submit onclick="setSubmitAction(<bean:message key="MyPanel.theField.label"/>)"><bean:message key="MyPanel.theField.label"/></htm:submit>
Some time I also need to pass a java variable as the parameter to a javascript function, and I encounter the same problem. For example,
<html:submit onclick="setSubmitAction(<%= myVar %>)" >
myVar will not get evaluated.
Can someone shied some lights on this?
Thanks a lot,
Catherine
-------------------------------------------------------------
<a href="http://Struts_User_List.roomity.com">roomity.com</a>
roomity.com is broadband internet. ~~1127830842502~~
-------------------------------------------------------------