struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>
Subject Reuse of Actions trough s:action. Objectives and inconveniences.
Date Mon, 23 Apr 2012 08:05:43 GMT
Hi,
  We are developing an web application that uses Struts2 + Tiles + JSP,
plus Dojo for the UI. The application uses the JSON plugin, since we do a
lot of interactions through AJAX calls using JSON. We are also building a
thick client that will only uses JSON to communicate with the server. It
will invocate Struts2 actions to retrieve information, and those actions
will provide a JSON result with the information solicited. Some of those
communications will download list of thinks (list of documents for the
user, for example).

   The thing is that we want to avoid duplications of code, so in order to
reuse those actions that produce JSON for the thick client, we are using
those same actions to get the same information for the browser. We have
made the pages compatible with that; the browser uses AJAX calls to call
those actions and show the retrieved information. But that also implies a
lot of HTTP connections to the server, which we would like to avoid.

  The way we have thought to avoid those extra communications is to use the
tag <s:action> on the JSP. That way the action is invoked inline from the
presentation layer, and the information(the JSON returned by the action)
incorporated on the JSP and sent to the browser, where the UI is created
with Dojo and shown to the user.

  The only problem I see is that the list of interceptors is fully executed
when calling those actions from the JSP. It makes sense, of course, but
that also add a lot of overhead I woiuld like to avoid.

  Does anyone see some obviouse flaw on this design? Is there a better way
to provide that JSON information without duplicating code and avoiding the
overhead?

Thanks

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message