Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing variable to actionLink

Status
Not open for further replies.

RidgewayM

Programmer
Jan 22, 2005
9
CA
Hi All,
I'm new to JSP. Can anyone tell me how to pass the dirname variable below into the actionLink tag?

<% String dirname="google.com";%>

<a:actionLink href=" + <%= dirname %> target="new" value="click Here" />

Thanks in advance for any help
 
Code:
<a:actionLink href="[URL unfurl="true"]http://www.<%=[/URL] dirname %>" target="new" value="click Here" />


Cheers,
Dian
 
Thanks for your reply, Dian.

I tried your suggestion but all I get is dirname%> in the hyperlink. ActionLink is a custom tag that obviously behaves differently than expected. I'm going to try and use <c:set>

Regards,
 
Argh, didn't notice the actionLink thingie. With JSTL would be something like

Code:
<c:set var="dirname" value="[URL unfurl="true"]www.google.es">[/URL]
<a:actionLink href="[URL unfurl="true"]http://${dirname}"[/URL] target="new" value="click Here" />



Cheers,
Dian
 
thanks for your help, Dian, but it looks like I'll have to abandon the actionLink idea and go back to straight html in the jsp page. When I put the ${dirname} in the actionLink as you suggested, I get in the hyperlink on the page.

Thanks again.

Regards,
 
What about a # instead of $?

Code:
<c:set var="dirname" value="[URL unfurl="true"]http://www.google.es">[/URL]
<a:actionLink href="#{dirname}" target="new" value="click Here" />



Cheers,
Dian
 
Hi Dian,
I tried your suggestion

for:
<a:actionLink href="#{dirname}" target="new" value="click Here" />

the page returns the alfresco login url

for:

<a:actionLink href=" target="new" value="click Here" />

the page returns
Looks to me like actionLinks do not handle dynamic variables
 
Well, at least it looks like the variable is being recognized, despite of the lack of value. The difference between # and $ has to do with when the it's rendered, as shown here

Maybe it's worth to try a scope change, as shown here with something like

Code:
<c:set var="dirname" value="[URL unfurl="true"]http://www.google.es"[/URL] scope="session">
<a:actionLink href="#{dirname}" target="new" value="click Here" />


Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top