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

In Struts can i have more that one form on a page

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I would like some of my pages to have more than one form allocated and therefore passed to the action class for processing. Is this possible without resonable fuss. Are there examples? I would like to have a form class associated with each table and petsistable object. Nice clean design but the front end has pages where updates are made to more that one table. Thanks for any help.
David
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would have to use different action mappings. E.g.
<action path="action/form1" type="myAction" name="form1" >
...
<action path="action/form2" type="myAction" name="form2" >
...
Then you'd have to dispatch requests depending on the type of form received. One of the first things you might try would be a series of if statements that tests for specific instanceofs your different forms but this isn't ideal, especially if it's possible that new form types will be added in the future. But then again, DTSTTCPW and YAGNI, so if you can live with it for now...
[ April 18, 2003: Message edited by: Junilu Lacar ]
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, your current design may seem clean and simple at first but making a form correspond to a single table/persistable object is mixing your layers and coupling the wrong ones together.
ActionForms should be more tightly coupled to the JSPs that they work with since the form is part of the view layer. Your table is part of the db layer. Your persistable object probably straddles your Model and Persistence layer.
The ActionForm should be used to relay information between the View layer and Model layer, not from the View directly to the Persistence layer. Let the Model worry about relaying the information to the appropriate Persistence layer objects.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic