This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Struts and the fly likes struts html: tags within jstl forEach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts html: tags within jstl forEach" Watch "struts html: tags within jstl forEach" New topic
Author

struts html: tags within jstl forEach

ralphy orientis
Greenhorn

Joined: Jul 29, 2005
Posts: 1
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
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
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}"/>


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts html: tags within jstl forEach
 
Similar Threads
Need to find a way without scriptless.
Select dinamically with radio buttons + indexed Form
Jstl with Struts Html tags
Validating struts <html:radio> button
html:radio..