• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hidden message?

 
Carol Murphy
village idiot
Bartender
Posts: 1202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
< input type='hidden' value='add a new video' name='action' >
< input type='submit' value='add a new video' name='submit' >

I'm working on a Cattle Drive assignment, and part of the given code includes a form with the above buttons. The value of both buttons is the same, but the name is different. I assume that the one named action will be used by an action handler, but I don't understand the need for the hidden button. Wouldn't it be the same if there was one button like so:

< input type='submit' value='add a new video' name='action' >

Could you use the form data submitted by the above button in the same way you could use the data submitted by the pair of buttons above?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64175
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 'hidden' element is not a button. It acts just like a 'text' input except that it is hidden from view. When the form is submitted, a request parameter named action with the value 'add a new video' will be submitted to the server.

Now, as to whether it's redundant or not depends upon how the server component is written. To me, it looks like all the info needed is available from the submit button.
[ March 24, 2006: Message edited by: Bear Bibeault ]
 
Carol Murphy
village idiot
Bartender
Posts: 1202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha! Perhaps then the value submitted by the 'hidden' element would be used to call a method in the servlet I'm supposed to write, and a different value submitted by a 'hidden' element in a different jsp would be used to call a different method. Hmmmm. A clue perhaps.
Would getting the value from the 'hidden' element be done through the use of getParameterValues( "action" ), as it would for a text field?
[ March 24, 2006: Message edited by: Carol Murphy ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64175
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Request parameters are simply a map of name/values pairs. From the point of view of a servlet, or any other server-side mechanism), the type of element (text, hidden, password, dropdown, and so on) that generated the parameter isn't even known.
 
Carol Murphy
village idiot
Bartender
Posts: 1202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool! I never knew that. Thanks, Bear.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64175
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic