struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <ahardy.str...@cyberspaceroad.com>
Subject Re: ensuring valid forwards
Date Tue, 14 Jun 2005 17:27:47 GMT
The best way that I have found to counter this is to stick rigidly to a 
limited set of forward names, such as 'display', 'failed', 'insert', 
'delete'.  Hard-code them in a utility class as string finals, or as an 
enum if you use jdk 1.5.

Make it part of your coding convention only to refer to map forwards 
from the utility class, so you are using only these strings as forward 
names.

To avoid the problem with the blank page, set up global forwards with 
those names as well, and send them to an error page with an obvious 
error msg. The global forwards will be used by default when there is no 
local map-forward in your action mapping.

I know there are often situations where a page has many possible 
consequent actions so you might not want to define your map-forward name 
set so rigidly. However such pages are big and cumbersome with lots of 
command buttons and I prefer to break them down into smaller pages.

Regards
Adam






On 13/06/05 21:15&nbsp;Hubert Rabago wrote:
> I recently checked in a change that would log a warning if
> mapping.findForward was called with a forward name that wasn't
> recognized.  This change didn't make it to the 1.2.7 release, but is
> available from nightly builds.  Apart from that, it wouldn't be too
> hard to customize/extend your Struts installation to handle it the way
> you'd wish.  You can use a custom request processor that'd log or
> redirect or even use a custom ActionMapping class that can intercept
> findForward() calls.
> 
> Hubert
> 
> 
> On 6/13/05, Dan Tenenbaum <dandante@gmail.com> wrote:
> 
>>My codebase has a lot of lines like this in struts actions:
>>return mapping.findForward("foo");
>>
>>If I make a typo and it turns out that "foo" is not a valid forward
>>according to the struts config file, when I hit the action in the
>>browser, I get a blank page. Not my designated error page.
>>
>>Is there some sort of struts-centric way to ensure that an exception
>>is thrown and my error page appears? I just want to know if there is
>>an existing mechanism to do this. I could easily write a method to do
>>it (to be called instead of mapping.findForward()) but it seems that
>>this is something Struts should handle.

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


Mime
View raw message