JQuery event trigger result in WebWork 2.2.x and Struts2, Part 2

In my last post I showed you how to create a JQuery result type for Struts and WebWork 2.2.x. This post will illustrate how to make use of the result. You will need 3 JSPs: an editor page, a list page, and a “container” page. The container page will typically contain some wrapper-type HTML, a link to add an object and other data that is essentially static in this context.

Jed Prentice
Posted

In my last post I showed you how to create a JQuery result type for Struts and WebWork 2.2.x. This post will illustrate how to make use of the result. You will need 3 JSPs: an editor page, a list page, and a “container” page. The container page will typically contain some wrapper-type HTML, a link to add an object and other data that is essentially static in this context. The list page displays the list of objects, and the editor page contains the editor form and its fields.In my last post I showed you how to create a JQuery result type for Struts and WebWork 2.2.x. This post will illustrate how to make use of the result.

You will need 3 JSPs: an editor page, a list page, and a “container” page. The container page will typically contain some wrapper-type HTML, a link to add an object and other data that is essentially static in this context.

The list page displays the list of objects, and the editor page contains the editor form and its fields. The container page has divs that will contain the list and the editor. The contents of each div come from AJAX requests for actions that render the list and editor pages upon success.

We also bind the document the refreshList event that we defined as the “success” result in part 1 to refresh the list when the page is loaded or the editor dialog is closed.

We can also define a delete action that maps success to this event to delete objects from the list and display the result. This is a summary of how to hook this up.

I had originally intended to include code samples and such but I wasn’t sure they would make a whole lot of sense out of context, so I scrapped that idea. Maybe if there is some interest I’ll put together some sample code. Let me know if you’re interested in seeing examples!

Jed Prentice