• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamically assign a name to a textfield

 
RohitPrakash Shinde
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
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.
 
Paul Clapham
Sheriff
Posts: 21113
32
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