Greg -
In order to open the dialog, you simply need to initially define your
dialog in your JSP. I prefer to use dynamic invocation of my dialogs,
especially in the scenario where I need to pass dynamic values such as
URL parameters to the dialog in the event I am editing multiple records,
say in a table or grid.
1. Define your dialog in your JSP like:
<sj:dialog id="myDialog" autOpen="false" modal="true" width="525"
position="[150,250]" onCloseTopics="myDialogClosed"
onCompleteTopics="myDialogOpened" resizable="false" />
I have my dialog defined to not auto open, be modal when invoked, and to
be positioned at a given location and to fire a few topics based on some
dialog events.
2. Bind a click event to something to invoke your dialog
jQuery(document).ready(function() {
$("#myid").click(function(event,data) {
var url = "build my url here";
$("#myDialog").load(url, function() {
$(this).dialog("open");
});
return false;
});
});
When the DOM is ready, I tie a click event to a DOM element. I build my
URL when the user clicks the element and pass that URL to my dialog to
be loaded. When the dialog has loaded the URL content, I then invoke
the dialog open to render the screen. If your content you need to show
can be built inside the <sj:dialog/> tags when you initially render the
page and doesn't need to be remote/dynamic called, you can do that and
simply call change the above function to:
jQuery(document).ready(function() {
$("#myid").click(function(event,data) {
$("#myDialog").dialog("open");
});
});
3. Setup your form and tie a click event to your submit button
When you click the button, you make an AJAX call to the server to submit
your data. If you get a successful result, you can then call
$("#myDialog").dialog("close") to close the dialog window and if you get
an error, you can then overlay another dialog to display the error or
set a div in your form you rendered in the dialog with the error
message.
Inevitability it boils down to a number of topic publish/subscribe
events you need to handle.
Any questions, hit me up off list.
Chris
> -----Original Message-----
> From: Greg Akins [mailto:[email protected]]
> Sent: Thursday, February 17, 2011 4:09 PM
> To: [email protected]
> Subject: Help with JQuery plugin
>
> I'm trying to implement a modal dialog in a Struts2 application.
>
> I found the struts2-jquery-plugin.
>
> What I'm not sure about is how to implement a dialog that contains a
> form. I'm trying to implement a feature to edit the value in a page
> by displaying the dialog with a <s:form/> and submitting that form to
> an action as the dialog is closed.
>
> The examples in the struts-jquery-plugin wiki don't seem to cover this
> case; though I've been fighting this (along with some other attempts
> using SimpleModal) for a day now and am hoping someone can point me in
> the right direction.
>
> Thanks.
>
>
>
> --
> Greg Akins
> http://twitter.com/akinsgre
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]