• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic Data Input and Bean

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am stuck up in following problem.. I've to use this concept in my application.
getter and setter methods are used in Beans for getting/setting values from JSP.
So far I've seen only one data 'string' in setter methods when it is set thru JSP.
What to do when we want to set "array of strings" thru JSP.
Suppose application prompts user to give size of a two dimensional string array( a X b)
If user enters 2 X 3 , then next JSP page should give a grid to enter data in 2 X3 format.
Now how to take these values in variables and user setter methods of bean to take value in two dimensional array ??
How the variables in JSP/HTML will be named in such case when columns and rows both are variables ???
Please HELP ???
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use javascript/HTML form field to receive the input from the user (the value of each cell in the 2D array).
Use a loop to generate the HTML, otherwise, you'll be hardcoding <TD> tags forever if your 2D array is large. For instance,

Now, as part of your form, you will have a table cell with the name of the row, followed by a '#' delimiter, and then the column(i.e. "0#0", "0#1", "1#0", "1#1"...). This makes it easy to parse the names. When you submit this form, the page which accepts the submission will have a similar loop to iterate through each parameter and store the value in your Java 2D array.
Hope this helps,
WS
 
catch it before it slithers away! Oh wait, it's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic