• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Creating an editable table using an array of input tags

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. I will give it a try and post the results.
 
Sheriff
Posts: 67762
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic