• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating an editable table using an array of input tags

 
Jerry Goldsmith
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning,

I am displaying a table of values on a jsp page using an array of input tags. The name attribute of the tags is dynamically generated to correspond to an array element in my Java bean. The trouble is, the attribute in the bean is not being populated when the page is submitted. The name attribute is currently of the form "cells[i][j]". I have also tried the form "cells" and "cells[]" to no avail.

Has anyone had any luck writing array values back to a bean using the name attribute? Can anyone suggest a better way to create a table, on a web page, which may be edited and the resulting values sent to a bean? Thanks in advance.

Here are the relevant lines of code from the bean:



Here is the jsp:



This is where I log the values to a file on the next jsp page:

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make life easier:
1) Use a List<RowObject> instead of SomeObject[][].
2) Use taglibs and EL instead of scriptlets.
3) Use JSTL's c:forEach to iterate over the List<RowObject>.
4) Use a servlet and the methods provided by HttpServletRequest to set submitted values back.
 
Jerry Goldsmith
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I will give it a try and post the results.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may take a little effort to pull yourself into the modern era, but trust me, it will be well worth it!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!