struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <>
Subject ActionForward question & encoding URL's
Date Wed, 23 Jul 2003 00:08:15 GMT

The only way I've ever used an ActionForward is by looking it up from the
ActionMapping... mapping.findForward( "someString" );

Today I really needed to set some request parameters, and of course there is
no request.setParameter() method.  I know there's some way to use a request
wrapper, but that didn't seem right.  So I pieced the URL together and
created a new ActionForward.

I have a form into which the user types a name.  The webapp then displays a
"resolution screen" of possible matches so they can pick one, then they go
back where they came from with that choice selected.  (Done by an awful
arrangement of setting request attributes, and the resolution form isn't
even a Struts form since I don't know until request time what the <form
action="..."> should be.  And it doesn't post to itself.)

Except if there is only one match, I don't want to show the resolution
screen, I want to go right back to the original form.

So here's what I have if resolution only turns up one hit:

String path = "/" + request.getAttribute( "returnTo" ) 
             + "?selectedId=" + selectedId
             + "&userAction=" + request.getAttribute( "userAction" )
             + "&returningFromResolution=true";

return new ActionForward( response.encodeURL( path ) );

(While we're here, I looked in the Struts source code for a hint on encoding
URL's, and found response.encodeURL().  Older code had URLEncoder.encode(),
but I didn't find that class in a quick search.  Comments?)

So, does the code above send anyone into screaming fits of "Don't DO that!"?
I'm not entirely sure what Action Chaining _is_ but I think I might be doing
it.  I'm up for suggestions on the reusable resolution Action and Form, I'd
rather it be a Struts form, but I'm not sure how to do it.

Thanks in advance for the pearls of wisdom.

Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM 

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