On Mon, April 10, 2006 2:09 am, Quinn Stone said:
> Frank, thanks for the link to javawebparts. The source code there helped
> me a
> great deal.
Good deal, glad to hear it!
> My next question is whether there's a mechanism by which I can stick an
> ActionError in the request so that the error page can display a message to
> the
> user using the familiar Struts <html:messages> tag.
Take a look at the addMessages() method of the base Action class in the
Struts source. No, wait, I'll save you the time... from 1.2.4...
protected void addMessages(HttpServletRequest request, ActionMessages
messages) {
if (messages == null){
// bad programmer! *slap*
return;
}
// get any existing messages from the request, or make a new one
ActionMessages requestMessages =
(ActionMessages)request.getAttribute(Globals.MESSAGE_KEY);
if (requestMessages == null){
requestMessages = new ActionMessages();
}
// add incoming messages
requestMessages.add(messages);
// if still empty, just wipe it out from the request
if (requestMessages.isEmpty()) {
request.removeAttribute(Globals.MESSAGE_KEY);
return;
}
// Save the messages
request.setAttribute(Globals.MESSAGE_KEY, requestMessages);
}
Add this to your filter, import the appropriate classes (Globals,
ActionMessages) and you should be all set. Use it just like you would in
your Action.
> Q
Frank
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]