Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How and What Do I do with the Enumeration Data

 
Steve Dyke
Ranch Hand
Posts: 1718
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have got my form posting its parameters and values to the servlet:

The form is a dynamic table populated by JSTL so the tag names(input and radio buttons) are dynamically created and assigned.

Servlet code:



However, the data is not in any kind of order. How do I make the data useful to send to my java class for remote source processing.

The data returned is:

statusoptions5~1
statusoptions4~3
statusoptions3~3
statusoptions2~1
statusoptions1~3
comments6~Auto Populated
comments5~T4
comments4~Auto Populated
comments3~Auto Populated
comments2~T3
comments1~Auto Populated
idname6~23
idname5~22
idname4~21
idname3~20
idname2~19
idname1~18
statusoptions6~3


I need it in this order:

idname1~18
statusoptions1~3
comments1~Auto Populated
idname2~19
statusoptions2~1
comments2~T3
etc.

Or an array
(18,3,Auto Populated)
(19,1,T3)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65545
110
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no way to guarantee any order among the request parameters.
 
Steve Dyke
Ranch Hand
Posts: 1718
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:There is no way to guarantee any order among the request parameters.


I kinda figured that.

Can you help me figure out an effective way to sort through what is returned so I can crate an array of values?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65545
110
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I'm not at all understanding what you are trying to accomplish....
 
Steve Dyke
Ranch Hand
Posts: 1718
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:As I'm not at all understanding what you are trying to accomplish....


The user opens a page with a list of options in a header div. Each option populates a main div four column table(using JSTL) with item numbers, a description of the item(only for info, not returned to sevvlet), and three radio buttons for each row(Yes,No,N/A), and a comments text area. The user fills out the form then submits it.

This is where I am at where the Servlet has gotten the parameters and their values in the Enumeration loop.

The data the Servlet gets for one example is:

The data returned is:

statusoptions5~1
statusoptions4~3
statusoptions3~3
statusoptions2~1
statusoptions1~3
comments6~Auto Populated
comments5~T4
comments4~Auto Populated
comments3~Auto Populated
comments2~T3
comments1~Auto Populated
idname6~23
idname5~22
idname4~21
idname3~20
idname2~19
idname1~18
statusoptions6~3

The idname is the item number column.
The statusoptions is the radio button that was selected.
etc.

As I said I need an array of each set of parameters. In this case a(6,3) array.

I will then insert this data into a remote database table. The item number will be a key field in the data file.
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You posted some data and said "this is the order I want it in". But I don't see what the reasoning is behind that ordering. If you want code which orders the data like that, you first have to be able to explain how to do that ordering.
 
Steve Dyke
Ranch Hand
Posts: 1718
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:You posted some data and said "this is the order I want it in". But I don't see what the reasoning is behind that ordering. If you want code which orders the data like that, you first have to be able to explain how to do that ordering.


The data the Servlet gets for one example is:

The data returned is:

statusoptions5~1
statusoptions4~3
statusoptions3~3
statusoptions2~1
statusoptions1~3
comments6~Auto Populated
comments5~T4
comments4~Auto Populated
comments3~Auto Populated
comments2~T3
comments1~Auto Populated
idname6~23
idname5~22
idname4~21
idname3~20
idname2~19
idname1~18
statusoptions6~3

Each string consists of the tag name, status.count(JSTL forEach), ~ separtates this from the actual value of each tag.
Next if you look close there are three string for each status.count value. The page that was submitted has a table which was populated by JSTL.

Row 1 has idname1, statusoptions1, comments1
Row 2 has idname2, statusoptions2, comments2
etc.

This is what I posted earlier:

I need it in this order:

idname1~18
statusoptions1~3
comments1~Auto Populated
idname2~19
statusoptions2~1
comments2~T3
etc.

Or an array
(18,3,Auto Populated)
(19,1,T3)
 
Steve Dyke
Ranch Hand
Posts: 1718
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you give up on me and this issue?
 
Sathish Kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need it in the order you have mentioned, try naming the form parameters in the below way

row1_idname, row1_statusoptions, row1_comments
row2_idname, row2_statusoptions, row2_comments

and sort the result once you get the request parameters in the servlet.

Let me know if I did understand your problem correctly.
 
Steve Dyke
Ranch Hand
Posts: 1718
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sathish Kumar wrote:If you need it in the order you have mentioned, try naming the form parameters in the below way

row1_idname, row1_statusoptions, row1_comments
row2_idname, row2_statusoptions, row2_comments

and sort the result once you get the request parameters in the servlet.

Let me know if I did understand your problem correctly.


For better or worse this is what I came up with:

 
Tell me how it all turns out. Here is a tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!