Author | Message |
---|---|
abhishek_sharma
Posts: 79
|
Posted 12:58 Sep 07, 2012 |
I have an "Add Album Button" in view /allAlbbum.html page. When I click this button it takes me to /album/addAlbum.html page. So I have two method addAlbum with RequestMethod Get and Post, all this working fine. What I want is on click of button it show a jQuery Modal with that addAlbum jsp. I made is work by making RequestMethog.GET to return ModelAndView on click of button it do an ajax call get whole form as a response and append it to dialog div and show the dialog. Problems here are: 1) I have to create a different template as I can't use default template which lead to load few css and js again so its like an iframe 2) On submit "Add Album" button on form it actual post using modelAttribute to second method with RequestMethod.POST and then I am doing redirect, so I am reloading same /allAlbum.html again. Is there any way I pass modelAttribute using ajax ?? May be I sound confused,but if anyone know better way to integrate Spring form and jQuery Modal Thanks |
cysun
Posts: 2935
|
Posted 13:57 Sep 07, 2012 |
I assume by "jQuery Modal" you mean a jQuery UI modal dialog. A dialog is part of a page, not a complete page, so obviously you shouldn't create the view like others with header, footer, etc. The dialog should follow the styling of the page that contains it though. The easiest way seems to be just putting the form in a dialog <div> inside the same page that contains the Add button. If you have to use Ajax then just make sure the returned view is just the form, not an entire page. I don't get your problem #2 though as it looks like the correct behavior to me, unless you don't want the page refresh, in which case you'll need to make the form post request Ajax, too. Note that in either case you may run into some difficulty if you use Spring validators and a user enters something wrong. If you can't get that part to work (which I think is a little tricky), just use jQuery Validation to do client-side validation. |
abhishek_sharma
Posts: 79
|
Posted 14:07 Sep 07, 2012 |
Going with the easiest way I believe I have to do something like this
@RequestMapping(value = "/admin/category/allCategories.html", method=RequestMethod.GET)
here onSubmit I will call "POST"method using AJAX |