• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

dynamic iteration of href attribrute in html:link tag?

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot for your time, Srikanth Shenoy.
you've been very helpful!
b
 
I was her plaything! And so was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic