struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Vincent Craven" <p...@cravenfamily.com>
Subject Getting MessageResources from Action
Date Tue, 17 Jun 2003 16:13:49 GMT
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


Mime
View raw message