Back Forum Reply New

Help! Multiple forms in one view?

I'm working on a webapp with a bunch of administrative forms for adding things that appear as finite enumerations on the rest of the website (for instance, the administrators are allowed to add values to the popups on the rest of the site).

A concrete example here is Countries and States. When entering an address, I'd like only certain options to appear for State and Country (in a popup), and so they're stored somewhere in a database with the option for the administrator to add new countries at his discretion.

I'd like to have one page with a list of the current countries (with states kinda nested, outline-like) on the left, with a sidebar with two forms on the right.

The sidebar will have one form for adding a new country, and one form for adding a new state to an existing country.

How do I effect multiple forms in the same view?  I have two form controllers that have been tested independently and are correct, and have one view controller that gets the country list to put up on the table, which also works independently.

I've put two forms in my JSP, each has as its quot;actionquot; the viewname associated with the two forms, which have as their success and error views the original page.

The original page renders, but I get this error when I try to submit either form:

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'stateForm' available as request attribute

Any help?

--Jason

instead of having two form backing objects why don't you make one that aggregates the two?  Then you won't have the confusion of two form controllers and their two FBOs on the same page.

I think that's unnecessarily complicated.  If at a later date I wanted to again separate these two forms, it would be easier to already have the logic separated.

I feel this should be possible and have scoured the forums for reasons why it is not. If someone could just explain the Binding error I'm getting I might figure it out.

Then again I have some big projects (in school) due this week, so I really haven't looked at the code too in depth yet.

Does anyone have a working example of a single view that has two separate forms (that delegate to separate controllers)?  I'd be happy to see some working sample code.

Acutally, we get reuse by aggegating our key abstractions (domain objects) into our form backing objects.  That way every form that has an address simply includes address as a member.  

You could simply make domain objects for state and country.  Incorporate them both into your FBO.  If you want to split them, make new FBOs that only have state or country as members.

FBOs are one-off things that are tightly coupled to your web pages (which are generally one-off things)

I suppose my recourse is to create one aggregate FBO with enough information for both possible branches and have different values for the two submit buttons.

The controller would decide to do based on what submit button was pressed.

I've already got domain objects for the objects in my domain, surprisingly enough.

Ok, so I hate to reply to my own post again, but here goes.

How do I cleanly validate this aggregate form?  I don't care what they entered in the quot;addStatequot; box if they submitted the quot;addCountryquot; form, and vice versa.  So the validator needs to be able to see what's on the request, which is impossible.

Take a look at the AbstractWizardFormController which supports mutlipage validation.  Your use case is not necessarily a wizard, but you can still take advantage of this feature.

Sounds promising, but semantically I'm not sure I can come to terms with this (using a wizard controller to allow multiple forms per page)?  I'm sorry if I come across as picky here, but I am just trying to get to the bottom of this. I wish not to denigrate your contributions.

Thanks for your help. I have enough information now to at least make this work, but I won't have free time to code on it until Thursday, so I'll table this for now and let this thread die.

Hello guys,Im newer to here,This method Multible forms in one view is possible in PhP(Hyper Text Preprocessor).Its a web development application.In this Php we can submit so many or multple or more than one form and we can get them and see in to one viewi mean single view.In the same method applicable for Visual Basic and the AbstractWizardFormController which supports mutlipage validation.

Online schools

Online universities
¥
Back Forum Reply New