struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Jouravlev" <jmi...@gmail.com>
Subject Re: Loosely coupled pages and actions
Date Thu, 04 May 2006 05:03:49 GMT
On 5/3/06, Rob Manthey <struts-user@rob.manthey.id.au> wrote:
> Hi,
> I have some actions that I have decoupled from their jsps, so that I can
> use the corresponding html components on various pages and move them
> around as the client changes their mind about requirements.
> I have implemented a programmatic mechanism for the action to know which
> assets to populate and which jsp to render after the action has
> completed, but it's getting a little tricky with some boundary fault
> cases, as I've also implemented a window uniquifier to permit multiple
> browser windows being acted in without session collisions.
> Anyway, can someone point out what I've overlooked?  Is there a simpler
> (framework) way of a loosely coupled action knowing dynamically what jsp
> it's called from (esp: note the cases of the component being or not
> being in a jsp:include) so that it can populate the right assets and
> render the right jsp?

Unless it is the case of <jsp:include>, I personally believe that
action should not know or care to know where the request came from.
Anyway. In case of <jsp:include>, you can either pass a request
parameter using <jsp:param>, or you can check for
"javax.servlet.include.request_uri" attribute of request object to see
if the action is included and what is the address of included fragment
as well as of parent page. See servlet spec or check out Caucho FAQ
[1].

> Using the struts-config.xml action input entry
> only allows one point of origin, and using request.getRequestURI()
> returns the last *action* not the originating jsp to forward back to
> (not helpful when the last action is itself one of these decoupled
> actions, as opposed to an inital jsp entry action).

If you think of it, this is logical. When you click on the link in the
browser, there is no JSP anymore, there is just an HTML page
containing the location where the request is about to be sent. How
browser would know about your last JSP? If you like, you can stick
your last location into your HTML forms as a hidden field, or into all
links as a parameter in a rewrite-URL manner.

[1] http://www.caucho.com/resin-3.0/webapp/faq.xtp

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message