Sounds like you need to add a custom handler like so:

<global-exceptions>
<exception
    handler="com.company.handlers.EJBCreateExceptionHandler"
    key="error.persistence.create"
    type="javax.ejb.CreateException"
    path="/tmpl_main.jsp?page=/error/syserror.jsp"></exception>

....
</global-exceptions>

Your "EJBCreateHandler" class would extend from ExceptionHandler and
override execute.  In there you can then create the custom parameterized
messages you want.  In the execute method of a ExeceptionHandler you have
references to the form, the mapping, request/response, and the
ExceptionConfig.  The ExceptionConfig class has the message key (and type,
path, etc) contained in the exception mapping.

HTH,
Tim





|---------+---------------------------->
|         |           "Jim Kennedy"    |
|         |           <[EMAIL PROTECTED]|
|         |           om>              |
|         |                            |
|         |           10/29/2003 12:13 |
|         |           PM               |
|         |           Please respond to|
|         |           "Struts Users    |
|         |           Mailing List"    |
|         |                            |
|---------+---------------------------->
  
>------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                                          |
  |                                                                                    
                                          |
  |                                                                                    
                                          |
  |                                                                                    
                                          |
  |To: "Struts Users Mailing List" <[EMAIL PROTECTED]>                                 
                             |
  |cc:                                                                                 
                                          |
  |                                                                                    
                                          |
  |                                                                                    
                                          |
  |                                                                                    
                                          |
  |  Subject:      Exception handling 100% declarative                                 
                                          |
  
>------------------------------------------------------------------------------------------------------------------------------|



Caterpillar: Confidential Green                 Retain Until: 11/28/2003
                                                Retention Category:  G90 -
                                                General
                                                Matters/Administration




I would like to be able to customize the output when an exception is thrown
with minimal or no extra overridden classes.  My struts config (1.1) config
file looks like this:

....

<global-exceptions>
<exception
    key="error.persistence.create"
    type="javax.ejb.CreateException"
    path="/tmpl_main.jsp?page=/error/syserror.jsp"></exception>
<exception
    key="error.http.methodnotsupported"
    type="javax.mail.MethodNotSupportedException"
    path="/tmpl_main.jsp?page=/error/syserror.jsp"></exception>
<exception
    key="error.naming.namenotfound"
    type="javax.naming.NamingException"
    path="/tmpl_main.jsp?page=/error/syserror.jsp"></exception>
<exception
    key="error.servlet.illegalparameter"
    type="com.je.servlet.IllegalParamsException"
    path="/tmpl_main.jsp?page=/error/syserror.jsp"></exception>
</global-exceptions>


The properties file looks like this:

errors.header=The following system errors occurred:<ul>
errors.footer=</ul>
error.persistence.create=An error occurred attempting to create a database
record
error.http.methodnotsupported=This type of request is not supported for
this URL
error.naming.namenotfound=Lookup failed with naming service
error.servlet.illegalparameter=A required field or parameter is missing for
the request


The syserror.jsp file is simply:

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<TABLE border="0" cellpadding="5">
<TR>
<TD><html:errors bundle="systemerrorbundle" /></TD>
</TR>
<TR>
<TD></TD>
</TR>
</TABLE>

The above does work.  But I only get the properties file message printed.
I would like to do something like this:

error.servlet.illegalparameter=A required field or parameter is missing for
the request {0}

so that I can dynamically generate a message specific to the error.  In
this case I want to display whatever field is identified by the exception.
So if the exception is thrown like:

throw new IllegalParamsException("fieldXYZ is missing");

I would like to see "A required field or parameter is missing for the
request 'fieldXYZ is missing' "
Can I do this 100% in a declaritive manner?  Or how can I pull this off.

thanks






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

Reply via email to