You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sherlock Simon <Si...@pito.pnn.police.uk> on 2003/05/22 17:12:38 UTC

RE: How to handle key attribute of tag?

Does the following thread help at all?

I've got it sorted now.  By adding:
<message-resources 
key="MESSAGE_ERROR_PAGE" 
parameter="com.pnc.visor.ErrorPageResources" 
null="false"/>
I spotted that the error message I wanted to display also needed to be in
the new resopurce bundle so I added:
#Errors page header and footer
errors.header=<b>
errors.footer=</b>
error.contact.support=Please contact support and quote Error No: {0}

and everything now works as I want.
I don't like having to have separate resource files but hey, it works.
Thanks, Simon.
-----Original Message-----
From:	Sherlock Simon  
Sent:	22 May 2003 14:18
To:	'Struts Users Mailing List'
Subject:	RE: Customising <html:errors /> output

Is there something else I need to do as well?  I'm currently getting nothing
displayed.
I now have the following code:
errors.add(ActionErrors.GLOBAL_ERROR, error);
request.setAttribute(org.apache.struts.Globals.ERROR_KEY, errors);
The following in struts-config.xml:
<message-resources key="MESSAGE_ERROR_PAGE"
parameter="com.pnc.visor.ErrorPageResources" />
<message-resources parameter="com.pnc.visor.ApplicationResources" />
and the following in ErrorPageResources.properties:
#Errors page header and footer 
errors.header=<b>
errors.footer=</b>

The <b> and </b> will have text but are just for testing at the moment.
>As an aside, if you're creating errors in your action, the standard
practice is
>to use Action.saveErrors(HttpServletRequest, ActionErrors) instead of
explicity
>setting a request attribute.

This is because I'm using the following:
public ActionForward execute(Exception exception,
ExceptionConfig exeptionConfig,
ActionMapping mapping,
ActionForm formInstance,
HttpServletRequest request,
HttpServletResponse response) 
throws ServletException
>From a class that extends ExceptionHandler.
Thanks, Simon.
-----Original Message-----
From:	Kris Schneider [mailto:kris@dotech.com] 
Sent:	22 May 2003 12:53
To:	Struts Users Mailing List
Subject:	Re: Customising <html:errors /> output

The code:
new ActionError("errors.header.errorpage")
creates an error instance whose message is "<b>". Is that really what you
wanted or are you just using that to try and force a particular format?
If you want to use a different header and footer, try creating a separate
properties file, say ErrorPageMessages.properties, and include your
alternate header and footer using the standard keys:
errors.header=<b>
errors.footer=</b>

Then, in your Struts config file, include something like:
<message-resources key="MESSAGE_ERROR_PAGE"
parameter="ErrorPageMessages"/>
Finally, in your error page, use <html:errors> like:
<html:errors bundle="MESSAGE_ERROR_PAGE">
As an aside, if you're creating errors in your action, the standard practice
is to use Action.saveErrors(HttpServletRequest, ActionErrors) instead of
explicity setting a request attribute.
Quoting Sherlock Simon <Si...@pito.pnn.police.uk>:
> Is it possible to stop <html:errors /> from picking up the default
> errors.header and errors.footer?
> 
> We have a properties file with the following:
> #Standard error header and footer
> errors.footer=</ul><hr>
> errors.header=<font color="red">Please correct the following error(s)
> before
> proceeding:</font><ul>
> 
> #Errors page header and footer
> errors.header.errorpage=<b>
> errors.footer.errorpage=</b>
> 
> and for most errors the standard errors.header/footer are fine but for
some
> I want to use error.header.errorpage INSTEAD.  However, the following code
> gives me both:
> 
> errors.add(ActionErrors.GLOBAL_ERROR, new
> ActionError("errors.header.errorpage"));
> errors.add(ActionErrors.GLOBAL_ERROR, error);
> errors.add(ActionErrors.GLOBAL_ERROR, new
> ActionError("errors.footer.errorpage"));
> request.setAttribute(org.apache.struts.Globals.ERROR_KEY, errors);
> 
> Is it possible to "turn off" or ignore the standard header/footer?
> 
> Thanks, Simon

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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

****************************************************************************
********
Internet email is not to be treated as a secure means of communication.
PITO monitors all internet email activity and content.
This communication is intended for the addressee(s) only.  Please notify the
sender if received in error. Unauthorised use or disclosure of the content
may be unlawful. Opinions expressed in this document may not be official
policy.
Thank you for your co-operation.
****************************************************************************
********


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


 -----Original Message-----
From: 	Caroline Holanda [mailto:spencercaroline@yahoo.com] 
Sent:	22 May 2003 16:14
To:	'Struts Users Mailing List'
Subject:	How to handle key attribute of <exception> tag?

Hi List!

   Can anybody help me to understand well the meaning
of bundle and key atrributes of the exception tag
nested in <global-exceptions>? 

   How will the message defined in the key be shown in
the error page? I know I can define an error page in
the path attribute, but what kind of code my error
page should have to show the key message defined in
the key attribute?

   Thanks in advance!
   Caroline Holanda
   IT- Consultant

=====
******************************
Cuide das pessoas que vc ama! 
Elas são presentes de Deus!

_______________________________________________________________________
Yahoo! Mail
O melhor e-mail gratuito da internet: 6MB de espaço, antivírus, acesso POP3,
filtro contra spam. 
http://br.mail.yahoo.com/

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

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