Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

dynamic iteration of href attribrute in html:link tag?

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright...
I have the following code below which is indeed working just fine:
<logic:iterate id="myElem" name="listBean" property="collection" indexId="index" type="org.ctcgsc.fsg.teamengine.bean.dto.QuickLinkBean">
<tr>
<td width="3"></td>
<td class="bulletin" align="left">
<span class="bold">
<bean:write name="myElem" property="title"/> - 
<a href="<bean:write name="myElem" property="uri"/>"><bean:write name="myElem" property="uri"/></a>
</span>
</td>
</tr>
<tr><td height="4"></td></tr>
</logic:iterate>
Now basically what I would like to do is replace the common <a href></a> html tag with the new <html:link> tag in struts. As you can see above...I nest the bean in the href attribute above. Only I've tried a vast number of ways to do this for the href attribute in the html:link tag, but when it gets down to it, i don't know how to get the href attribute to spit out my uri bean property in an iteration. the uri bean property IS the href that i want to link to.
i'm sure this can be done somehow.
thanks to all who try!
bryan
 
author
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP tag spec does not let you to nest a tag as the attribute of another tag.
You have two options:
1)Evaluate the bean:write before hand and substitute it using scriptlet into the html:link tag
2) Or use Struts-EL to do dynamic evaluation. I had posted an answer in another thread in this forum on the same topic
https://coderanch.com/t/47628/Struts/html-link
 
Srikanth Shenoy
author
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I like to eliminate the scriptlets as much as possible in the JSP and use Struts-EL with JSTL as following:
<html-el:link href="${myElem.uri}"><bean:write name="myElem" property="uri"/></html-el:link>
OR
<html-el:link href="${myElem.uri}">${myElem.uri}</html-el:link>
 
bryan nelson
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot for your time, Srikanth Shenoy.
you've been very helpful!
b
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic