This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Concatenating textfield names with ${status.index} Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Concatenating textfield names with ${status.index}" Watch "Concatenating textfield names with ${status.index}" New topic
Author

Concatenating textfield names with ${status.index}

Arathi Shekhar
Greenhorn

Joined: Oct 04, 2005
Posts: 3
I have a table whose columns will be created dynamically depending on the
objects.
For example if we have customer then each column will have that object with
Name,Address,Phone etc as rows
I have named the textfields as name1,name2 etc for name dynamically by taking the ${status.index} value.And similarly fro the other fields.After
entering the details when I click on save it should perform validation in the server side and if any errors are present then it should display the value in the respective textfield with an error message.
I want to use if test = "${not empty param.name1}".
But is there any way of getting name1 or can I get name[0].

Thanks in advance,
Arathi
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
Validation should be done in java code rather than in JSTL.
JSTL is not suited for it.

The following code does demonstrate how to use dynamic names to access collections though. If you put all your errors into a map keyed by fieldName, the following would work:

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Concatenating textfield names with ${status.index}
 
Similar Threads
Strings aren't objects?
IE doesn't seem to reflect updated document object
Inheritance Trouble
help me deploy my webapp
adding rows in jTable