File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Dynamically assign a name to a textfield Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamically assign a name to a textfield" Watch "Dynamically assign a name to a textfield" New topic
Author

Dynamically assign a name to a textfield

RohitPrakash Shinde
Greenhorn

Joined: Dec 01, 2011
Posts: 2
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

Joined: Jan 10, 2002
Posts: 61103
    
  66

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
RohitPrakash Shinde
Greenhorn

Joined: Dec 01, 2011
Posts: 2
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically assign a name to a textfield