Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1 - Multibox Question

 
bryan nelson
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,

I'm trying find a way to have a more robust mapping of multibox data from a jsp page to a struts form. My question is, is the multibox tag bound specifically to a String Array in the struts form? Or could I use something like a map, or list, etc...something that is a bit more dynamic?

For example...if my multibox is bound to a property in my form called "selectedThings," does "selectedThings" have to be a String[]?

Thanks!
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bryan, this struts API link says that it takes only primitive array types may be not Maps..
 
bryan nelson
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that limits the robustness a bit.

As a solution I simply created a String[] inside one of my beans which was a field in the form. Although it added a layer of complexity when linking the specific checkbox with the specific String[] in each bean, it works well.

Crisis averted.
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally it is done, may be you can have a wrapper/generic class (since ther is no more upgrade to the struts version (1.x) being used) like formHelper which would help you for other similiar scenarios in future as well..

Anyways, its good to be closed
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic