struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Torbeyns <torbe...@yahoo.ie>
Subject Re: Getting MessageResources from Action
Date Wed, 18 Jun 2003 18:53:18 GMT
try the following in your action
Action.getResources(request).getMessage()


Tim


 --- Paul Vincent Craven <paul@cravenfamily.com> wrote: > I need to
break some with the MVC model, and
> output information from within my Action.
> 
> Specifically, I have a long running process that I
> give status updates to the user by putting info on
> the output stream and then flushing it.
> 
> My problems is that I want the messages displayed
> to the user to come from the application resources
> file. I've tried the code below, but getPageContext
> returns a null. I assume because I'm not really in
> a jsp/page. But I don't know another good way to get
> a message resources object. Can anyone offer advice?
> 
> JspFactory factory = JspFactory.getDefaultFactory();
> 
> PageContext pageContext = factory.getPageContext(
> 	MyServlet.getInstance(),
> 	request,
> 	response,
> 	null,  // errorPageURL
> 	false, // needsSession
> 	JspWriter.DEFAULT_BUFFER,
> 	true   // autoFlush
> 	);
> 
> messages = (MessageResources)
> pageContext.getAttribute(Action.MESSAGES_KEY,
> 			   PageContext.APPLICATION_SCOPE);
> out.print( messages.getMessage(defaultLocale,"errors.mymessage",
> myparametervalue) );
> out.flush();
> 
> Paul Vincent Craven
> paul@cravenfamily.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>  

________________________________________________________________________
Want to chat instantly with your online friends?  Get the FREE Yahoo!
Messenger http://uk.messenger.yahoo.com/

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


Mime
View raw message