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

jsp hidden field not populated in ActionForm

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've read many coderanch conversations and still need to ask:

Why doesn't the hidden field get populated to the ActionForm? It's like RequestUtils.populate ignores the field.

Then, how can I modify the same hidden field depending on which link the user selects? Should javascript and DOM work?




ActionForm




Action


web.xml


config




Thanks.

Matt

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTML Link does not carry the form data. You can either go for different submit buttons or pass the values as parameter to the action link and fetch it accordingly in action class. Use the rewrite tags to hide parameters it from the end users.
 
matt love
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jaimesh,

I had come up with a work-around, similar to your first solution with two Submits.

In the config I created two mappings, each going to the same Action, one mapping each from the two links with different actions, ie, <html:link action="/chooseDataStoreTypeDataBase"> for one and <html:link action="/chooseDataStoreTypeArray"> for the other. The config entries:



The trick was creating an Interface that each of the mapping's form extended. Each form had a different literal, eg, one form had private static final String dataStoreType = "array"; and the other private static final String dataStoreType = "dataBase";. Thus, in the Action I could test the Interface and polymorphically determine which Link sent the request.

I've since modified my solution by utilizing request.getRequestURI() in the Action.

Maybe not the most elegant solution, but it seems reasonable.

I included alot of the above code in case someone can use it later.

Thanks again.

Matt


 
Jaimesh M Ponkia
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you were using the hidden variable only to determine which link was clicked then you can go for using LookUpDispatchAction and set the action according to your link. This way you will not have to make 2 entries in struts-config and not worry about requestURI.
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic