Sneha Manohar wrote:
> 
> I have written my own exception handler 'MyException'  implementing
>  ExceptionHandler . Here I am trying to forward it to error page . How do
> I throw (call) this MyException from ActionBean. Following code does not
> work ..it says we incompatible type ..we need throwable.  Can you please
> send sample for handling exception using stripes
> 

First, you don't throw an ExceptionHandler, you throw an Exception.

Second, you don't have to call it from the ActionBean.  Just throw the
exception like you would any other exception.  That's the beauty of
extending your own ExceptionHandler... you can have it send the user to
wherever you'd like, based on the types of exceptions.  For example:

public class MyExceptionHandler implements ExceptionHandler {

  public void init(Configuration configuration) throws Exception {
    ...
  }

  public void handle(Throwable throwable, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
    if (throwable instanceof HibernateException) {
      new RedirectResolution("/MyError.action").execute(request, response);
    }
  }

}

public class RegisterActionBean extends AnoigmaActionBean {
 
  public Resolution registerUser() throws HibernateException {
    um.saveToDB(this.user,this.getCountryId());
    return new ForwardResolution("/login_step_end.jsp");
  }
 
}
Substitute whatever Exception you want to catch.
-- 
View this message in context: 
http://www.nabble.com/Exception-handling-in-stripes-tp22563861p22663042.html
Sent from the stripes-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to