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

Same element name in a form to servlet

 
Arvind Subramanian
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a form assume each row has 2 text box and totally 20 rows
so I have 2 X 20 =40 text boxes .

Each row means key - value pair , which i want to take to servlet.

wat i planned was naming all the element with 2 name as key and data
client side


server side


Doubt
whether in all times
id[1] == data[1]
Whether by index can we able to find the matching relation? is there any possiblility that index can be changed then order it was provided...

If its not understandable please post...
 
Sagar Rohankar
Ranch Hand
Posts: 2905
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doubt
whether in all times
id[1] == data[1]

You can check this at server side by printing the values.
Whether by index can we able to find the matching relation? is there any possiblility that index can be changed then order it was provided..

If index changed, then on javascript change the value.
 
Arvind Subramanian
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked and getting correct order as displayed, but it seems completely depends on browser. If browser sents in different order then my business logic will crash.
Its actually not to check the value.
It will update the DB with the data for coresponding key. so based on the index i will form the query string, so if the order changes then wrong data will be updated for the wrong row in the db.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Form elements are normally submitted in the order defined--but you'd have to check the spec to see if this is enforced by the spec. Even then, like you, I'd be nervous about depending on the browser to always do the right thing. Personally I'd consider using an indexed notation.
 
Arvind Subramanian
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
indexed notation ?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
foo[1], foo[2], etc.

Not using a framework that handles things like this automatically makes for extra work. You might be able to use an existing EL implementation to make things easier, but I've never actually tried using one outside of a framework that already supports it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Form elements are normally submitted in the order defined--but you'd have to check the spec to see if this is enforced by the spec.


It is not.

A framework isn't really needed. Using indexed notation means that it'd be easy to use normal bean injection into indexed properties. For example, the Jakarata Commons BeanUtils utility class will handle indexed properties nicely.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic