users
[Top] [All Lists]

RE: [cinjug-users] Struts question: how do you handle an undefined Actio

To: users@xxxxxxxxxx
Subject: RE: [cinjug-users] Struts question: how do you handle an undefined ActionForward value?
From: Brian K Bonner <brian.bonner@xxxxxxxxxxxx>
Date: Fri, 10 Dec 2004 18:04:53 -0500
Delivered-to: mailing list users@cinjug.org
In-reply-to: <OF1BB9CA27.95768BCA-ON85256F66.00766201-85256F66.00766B9D@paraware.com>
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Sure enough,  I just had a chance to try it:

putting:

        <action path="/unknown" unknown="true" 
forward="/unknownmapping.jsp" />

as one of the actions inside the action mappings.  forwards to whatever 
page /unknownmapping.jsp is.  It keeps the url reference (actually does a 
forward) and tells the user that the action isn't recognized.

Brian

Brian K Bonner <brian.bonner@xxxxxxxxxxxx> wrote on 12/10/2004 04:39:48 
PM:

> Cool.
> 
> Brian
> 
> steve.gutter@xxxxxxxxxx wrote on 12/10/2004 04:33:12 PM:
> 
> > 
> > 
> > 
> > 
> > unknown="true" worked fine (and, as is expected, you can only define 
one
> > action
> > with the attribute unknown="true")
> > 
> > getUnknown sounds like its working as documented:
> > it returned "true" when invoked from the action class defined with
> > unknown="true",
> > and returned "false" for 'regular' action classes.
> > 
> > Thanks for the info!
> > 
> > 
> > 
> >                       Brian K Bonner 
> >                       <brian.bonner@par        To: 
> > users@xxxxxxxxxx 
> >                       aware.com>               cc: 
> >                                                Subject:  RE: 
> > [cinjug-users] Struts question: how do you handle an undefined 
> >                       12/10/2004 03:24          ActionForward value? 
> >                       PM 
> >                       Please respond to 
> >                       users 
> > 
> > 
> > 
> > 
> > 
> > 
> > Steve, if you configure unknown="true" as part of your action mapping,
> > this action will be used if no action mapping is found and will 
forward 
> to
> > the appropriate mapping.
> > 
> > I have not done this (or tried it), but I just checked the java doc 
for
> > ActionConfig and found that getUnknown indicates if this ActionConfig 
is
> > the default config in case none is found.
> > 
> > thanks for the question--helped me learn something.
> > 
> > Give that a try and report back :)
> > 
> > Brian
> > 
> > "Hill, Richard" <Rich.Hill@xxxxxxxxxx> wrote on 12/10/2004 03:00:32 
PM:
> > 
> > > Subclassing ActionMapping definitely sounds like the most straight
> > > forward approach.  I'm kind of
> > > surprised there isn't any error thrown as it is.  I would also think
> > > that Struts would allow a default
> > > handler for if no matches occur.  Subclassing does seem to be the
> > > easy route though.
> > >
> > > -----Original Message-----
> > > From: Brian K Bonner [mailto:brian.bonner@xxxxxxxxxxxx]
> > > Sent: Friday, December 10, 2004 3:02 PM
> > > To: users@xxxxxxxxxx
> > > Subject: Re: [cinjug-users] Struts question: how do you handle an
> > > undefined ActionForward value?
> > >
> > > Good question.
> > >
> > > You're basically returning a null ActionForward from your Action,
> > because
> > > the page is not found by the ActionMapping.  It *is* because you 
have 
> a
> > > programming error in your app.
> > > You could subclass ActionMapping to return an error page if a 
forward 
> is
> > 
> > > not found (to help you as the programmer).  What do other struts 
folks
> > do?
> > >
> > > Brian
> > >
> > > steve.gutter@xxxxxxxxxx wrote on 12/10/2004 01:09:06 PM:
> > >
> > > >
> > > > Granted that it shouldn't happen, but how do you handle the
> > circumstance
> > > > when the ActionModel class's
> > > > execute method returns an ActionForward value which is not defined 

> as
> > a
> > > > forward name= value
> > > > in the ActionModel's action definition in struts-config.xml?
> > > >
> > > >
> > > > It causes the app to go to a blank page, but no exceptions, etc. 
are
> > > > thrown.
> > > >
> > > > I'm using the action entry with unknown="true" for the case where 
I
> > have
> > > an
> > > > href="xyz.do" and there is no
> > > > action defined for /xyz (which, again, granted shouldn't happen), 
> but
> > > this
> > > > doesn't catch the other scenario.
> > > >
> > > >
> > > > ---------
> > > > You may unsubscribe from this mailing list
> > > > by sending a blank email addressed to:
> > > > users-unsubscribe@xxxxxxxxxx
> > > >
> > > > --
> > > > Find additional help by sending a blank email
> > > > addressed to:
> > > > users-help@xxxxxxxxxx
> > > >
> > >
> > >
> > > ---------
> > > You may unsubscribe from this mailing list
> > > by sending a blank email addressed to:
> > > users-unsubscribe@xxxxxxxxxx
> > >
> > > --
> > > Find additional help by sending a blank email
> > > addressed to:
> > > users-help@xxxxxxxxxx
> > >
> > >
> > > ---------
> > > You may unsubscribe from this mailing list
> > > by sending a blank email addressed to:
> > > users-unsubscribe@xxxxxxxxxx
> > >
> > > --
> > > Find additional help by sending a blank email
> > > addressed to:
> > > users-help@xxxxxxxxxx
> > >
> > 
> > 
> > ---------
> > You may unsubscribe from this mailing list
> > by sending a blank email addressed to:
> > users-unsubscribe@xxxxxxxxxx
> > 
> > --
> > Find additional help by sending a blank email
> > addressed to:
> > users-help@xxxxxxxxxx
> > 
> > 
> > 
> > 
> > 
> > 
> > ---------
> > You may unsubscribe from this mailing list
> > by sending a blank email addressed to:
> > users-unsubscribe@xxxxxxxxxx
> > 
> > --
> > Find additional help by sending a blank email
> > addressed to:
> > users-help@xxxxxxxxxx
> > 
> 
> 
> ---------
> You may unsubscribe from this mailing list
> by sending a blank email addressed to:
> users-unsubscribe@xxxxxxxxxx
> 
> --
> Find additional help by sending a blank email
> addressed to:
> users-help@xxxxxxxxxx
> 


<Prev in Thread] Current Thread [Next in Thread>