This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

Spring help with JSP - One value through Multiple FormsPage Title Module

Spring help with JSP - One value through Multiple Forms

Jan 14th, 2005, 09:41 AM

Hey all,

I'm trying to create a view using JSP that will populate a selection box with simple name-only entities. Next to the box I want three submit buttons: Edit, Add, Delete.
I've got the Edit and Add buttons to work. The Edit uses the value in the box, and the Add doesn't need any value. The problem is that the Delete form requries the same value in the box that the Edit form requires.
I'm rather new to JSP, but is there a way to globally use an input value throughout separate forms? Here is what I have so far:

Comment

So there's no way to refer to the value that is inside of an input or select box? What's I'd really like to do is create a hidden input field within the delete form and set it's value to the value in the selection box. No go?

Thanks,
James

BTW - I wonder if your SimpleMultiActionController could be included within Spring. I really do like it for other forms.

Comment

There's nothing to stop you having two submit buttons with different names and/or values in the same form. Then the value of your selection would be sent with both. Test in your controller which button was pressed, and take the appropriate action.

Comment

Chris,
that is what the SimpleMultiActionFormController does, it invokes a different validator and form submission method depending on which submit parameter was passed in.

I can kind of see what JamesW is after and can be solved with javascript, but it would be easier to just use a single controller with a MultiAction parameter, set the action to "editDepartment.htm?mode=delete" and just have a single form.

SimpleMultiActionFormController is freely available to add to spring if its useful.

Comment

Yeah, I've had my eye on that SimpleMultiActionController since it was first posted. I think that is going to be the best way to go, since I'll have to end up using it several times. If I have any questions, would you mind if I posted them here?

Thanks,
James

Comment

Okay, after looking at the previous topic again, I've decided that my form is going to be simpler. However, I don't fully understand how the controller would be written with your code. All I saw was James Smith's example of a controller extending his SimpleMultiActionController.
Could you provide some example code of one extending your code?

Thanks,
James Winans

Comment

I dont think it is really necessary to use the SimpleMultiActionFormController because you really are not doing much with the form command objects binds you only have one parameter you are interested in. So there is easier ways to do this.

But as an example using MultiActionController with a submit parameter resolver, ill give it a go

This allows me to have any number of forms on one JSP page using multiple actions. I am using this page as a manager for all of the simple named entities that popluate drop-down boxes in my application.
So on one page, I can have a table that has a drop-down on each row filled with things like Department names, Title names, Status types - each allowing for add, edit, and delete funcationality.
I hope that helps anyone who may have a similar problem. Let me know if it wasn't clear enough. Thanks for the help everyone.