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

Same element name in a form to servlet

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
indexed notation ?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67750
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

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.
 
Good night. Drive safely. Here's a tiny ad for the road:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic