• 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

struts html: tags within jstl forEach

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hiya,

I have scoured the net for solutions to this, and have found little.
Perhaps I am missing something obvious but I was surprised because I thought this would be one of the most common things required in a Struts app !

I'd like to have a number of radio input fields on a form, when the IDs and properties contain their respective numbers. Given that there will be a variable number of radios, I'd like to render them dynamically from a c:forEach tag (the jstl equivalent of logic:iterate).

My aproximate goal is :

<input type="radio" id="opt1" name="optRads" value="val1"/>
<input type="radio" id="opt2" name="opRads" value="val2"/>
<input type="radio" id="opt3" name="opRads" value="val3"/>
etc

This is my foiled attempt :

<c:forEach var='i' begin='1' end='3'>
<html:radio styleId="${i}RadioInput" property="opRads" value="val${i}"/>
</c:forEach>

I've surrounded the var i in ${} to highlight where I want the dynamic content.

The result of this and all my other efforts including the following :

<c:forEach var='i' begin='1' end='3'>
<html:radio styleId="<%=i%>RadioInput" property="opRads" value="val<%=i%>}"/>
</c:forEach>

seem to fail. Please help, anyone who knows this most esoteric mystery !

Anthony
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to use expression language, you must use the EL tags for corresponding libraries. eg, there is html_el:radio tag that will understand the ${i}. <c:forEach
<html_el:radio styleId="${i}RadioInput" property="opRads" value="val${i}"/>
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic