Win a copy of Spring in Action (5th edition) this week in the Spring 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Dynamically assign a name to a textfield  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a JSP that contains a struts 2 textfield tag as follows:

I would like to dynamically assign a name to this textfield using the value of a variable I declare earlier in the code as follows:

I would like to give the textfield a name that is equal to the current value of the variable i.
Please advice.
 
Marshal
Posts: 67163
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
RohitPrakash Shinde
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But this is a JSP question.. I am using it with the Struts 2 framework but this has nothing to do with the struts framework . Therefore, I thought it to be a JSP question and hence posted it in the JSP forum.
 
Sheriff
Posts: 23868
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP question? Well, normally in JSP with the EL the name of the variable would be simply

But for some reason you've thrown some scriptlets in there. Normally in JSP with the <c:forEach> element you'd use the varStatus attribute to give you a variable which you can get the index number from, so you shouldn't need a scriptlet.

But you aren't using <c:forEach>. You're using a Struts iterator. So your Struts question is "How do I get a value which represents the number of times the code has been through the loop from an <s:iterator> element?"

So it's a Struts question.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!