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 12:47:46 UTC

Customising output

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


************************************************************************************
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


Re: Customising output

Posted by Kris Schneider <kr...@dotech.com>.
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