Adam Hardy wrote:
So struts marshalls the HTTP request params into a form bean and perhaps validates them. Also struts interfaces with the model when it calls business methods from action classes. But for Ajax requests then there is only ever one possible actionForward (or 2 if you count a global error). I can't imagine there's ever any need for doing different things with the data - it's (un)marshalled into xml, right?

XML in AJAX is completely optional. The form the result of an AJAX call takes is completely up to you... could be XML, could be JSON, could be HTML, could be something entirely different that you make up.

There is just as much possibility of multiple forwards for an Action mapping that services an AJAX request as one that doesn't... you might have a single Action that really performs a couple of different functions, resulting in a number of different snippets of HTML being returned. In that case, you would still very likely want to use JSPs to render those snippets, in which case you may well have a number of forwards. What happens though is that conceptually, forwards are no longer associated, necessarily, with page (or view) transitions. You can *almost* view them as calls to some method that generates a final result.

With AJAX, it becomes very natural to think in terms of services rather than pages... many AJAX apps load one master HTML document at the start, and from then on the changes to the views are just bits of markup that get displayed, or data used to generate new bits of markup to be displayed. Then, an AJAX call is really just a request for the server to perform some service and send back a result, which may or may not be directly displayed to the user. The transitions between views is largely a function of the client (some say the C in MVC moves to the client).

Frank

Adam Samere on 24/05/06 22:57, wrote:
I've recently used AJAX in some existing Struts applications making use of AjaxTags http://ajaxtags.sourceforge.net/. The Struts controller is still very much applicable, in that the Ajax requests are made to struts action urls, the action subclasses then delegate processing to business objects in the same way as we're used to, and finally forward to a JSP for generating the output. The major difference is the JSP's generate XML responses, rather than HTML/XHTML. Essentially they return either a page fragment or an XML item list of some type which is then parsed and stuffed into the client side DOM using javascript for immediate display.

Adam Hardy wrote:
I have only a small knowledge of the Ajax frameworks out there and I am trying to work out how much an Ajax app would depend on Struts.

I assume the view in an Ajax app is handled at the initial request by a JSP with HTML and that afterwards every request from the browser is XHR, ideally broken down on a per-data-item/list basis. The view HTML is from there on in handled by Ajax. In that case the Controller part of MVC would be managed entirely client-side. Therefore all that struts would have to offer the app would be Validator and perhaps a couple of other services. Or am I totally wrong? Can struts offer the ability to manage the Controller part of the app in such a way that the project could have two views - one in Ajax and one in JSPs?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Java Web Parts -
http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to