View Full Version : Dialog box as form in spring..
Prasi
Sep 29th, 2010, 01:28 AM
Hi,
I am now having an requirement, to bring a DOJO dialog box, as a form view, when we invoke the spring controller.. can we do it? if yes, how can we do it? Also, if DOJO dialog is not possible, is there any other way in spring, where i can bring up the dialog box..
F.Degenaar
Sep 29th, 2010, 03:29 AM
The tricky part isn't the dialog box itself, but handling the reply from the server.
Technically speaking, the dialog box is part of the underlying HTML page, unless it is opened in a new browser window or tab, so nothing special there.
Usually, a new page will be sent to the browser, if you submit the form to the server. The dialog box will disappear of course. If that works for you, you can use Spring MVC exactly the same way as you do without a dialog box.
Now, if the reply should appear in the dialog box, there are two options:
Option 1: you cheat and a new dialog box (looking the like the old one) is part of the new page you send from the server to the browser. Basically you send the same page, only the contents of the dialog box have changed. Depending on your environment, this might work. Again, nothing special here.
Option 2: you send the form to the server via JavaScript and subsequently incorporate the reply into the existing page via JavaScript, too. Even then, the controller can stay the same, but the view shouldn't be an HTML page, but something better suited for data like XML or JSON.
HTH
P.S.: You don't need DOJO or JavaScript for dialog boxes: http://thinkvitamin.com/design/how-to-create-a-valid-non-javascript-lightbox/
Prasi
Sep 30th, 2010, 11:23 PM
Thanks Degenaar for the reply, in option 2, you meant submission of form using AJAX? can you please elaborate more on option 2...
F.Degenaar
Oct 1st, 2010, 03:15 AM
Yes, I meant AJAX, even though the first "A" and the "X" are not necessary. My point was, that a Spring controller does not have to tell a regular HTTP request from an AJAX one. The only difference is in the view (HTML vs. XML or JSON). How to send the request and how to receive the reply from JavaScript is a client-side concern.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.