• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Multiple forms in Spring

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a jsp page in that i have multiple form tags like

<form:form action="action1.htm" method="post" commandName="commandName1" > </form>

<form:form action="action2.htm" method="post" commandName="commandName2" > </form>

<form:form action="action3.htm" method="post" commandName="commandName3" > </form>

<form:form action="action4.htm" method="post" commandName="commandName4" > </form>

in this , i want to call different controller for each action & return the ModelAndView Object to the parthicular form tag

Can anyone help me out on this?

thanks in advance

Karhtik
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think going for an annotation way would be a better solution here. because in that case we can handle all forms initialization inside a single controller all form handling also inside a single controller.
I don't know whether we can have array of command class or array of command names inside single controller much like supported http methods like get and post.

with annotaion when you create the form backing object you have to create all form backing object and set then in model map for preinitialization.
but would you please tell me why you need all forms in a single page.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is nothing to prevent you from having multiple forms on a page, just don't nest them. Typically with newer versions of spring you use the modelAttribute tag not the commandname tag. You obviously can't submit multiple forms at once, typically you would use AJAX for this. You have not really given us enough information to help you determine if the approach you are taking is the best one.
 
Ayan mallick
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think commandname and modelattribute are for diff pupose all-together. command name for initialization purpose by the name pre-intialized form is set in request when displaying form for first time.
model attribute is posted data which is set in request scope. correct me if i am wrong because that's what i know.
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They are absolutely identical. As a matter of fact I think in code one calls the other. CommandName just lingers on for historical reasons.

Discussion of it here: http://chompingatbits.com/2009/08/25/spring-formtag-commandname-vs-modelattribute/
 
Ayan mallick
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmm i didn't know that.That's why i love this forum so much
reply
    Bookmark Topic Watch Topic
  • New Topic