File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic Data Input and Bean

 
S Santosh Kumar
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • 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 ???
 
Winston Smith
Ranch Hand
Posts: 136
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic