Ovidiu,
I'd suggest using the declarative exceptions of Struts 1.1

http://javaboutique.internet.com/tutorials/excep_struts/index-3.html

It will save you a lot of duplicated code in your actions.
The servlet context is available through the
HttpServletRequest.getSession().getServletContext() in the
ErrorHandler class.

I'd also suggest using the DAO pattern and getting an instance of your DAO
class in your execute method. This will also let you have additional DAO's
if you add additional tables rather than adding more methods to your
GeneralImpl and General classes. You should also check out the iBatis or
Hibernate persistence frameworks.

Regards,

Richard


-----Original Message-----
From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 20, 2003 9:43 AM
To: Struts Users Mailing List
Subject: Re: Simulating multiple inheritance for Action and DispatchAction


Thanks anyway.
In fact it would be a little bit difficult to use ExceptionHandler since it
doesn't have a reference to the servlet. And I'm gonna tell you why I need
it ..:). The so called GeneralImpl, implements a method to retrive error
messages (based on their code) from database(I'm not using any
internationalization) using the servlet context in which I'm storing an
oracle connection pool (OracleOciConnectionPool created using a plugin).

So all my error messages are retrivied from the database using this method
(I know there is DBRessources which can integrates with struts but my
requirements are to use the same and only OCI connection pool used by the
rest of the
application)

The only solution to use ExceptionHandler, as far as I can see, would be to
implement my own RequestProcessor and to modify processException method
something like this

processException(..........){
...................
     try {
            ExceptionHandler handler = (ExceptionHandler)
            RequestUtils.applicationInstance(config.getHandler());
            if(handler instanceof MyHandler){
                ((MyHandler)handler).setServlet(servlet);
            }
            return (handler.execute(exception, config, mapping, form,
                                    request, response));
        } catch (Exception e) {
            throw new ServletException(e);
        }
}
and in MyHandler I'll have a method to get the error messages from the db
and the setServlet method. What do you think ? It could work ?

Ovidiu


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to