struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Viacheslav Novgorodtsev, E-Commerce SO" <VNovgorodt...@Actebis.com>
Subject RE: Converting an ActionError to a string programmatically
Date Wed, 09 Jul 2003 09:11:46 GMT
Example:
	ConfigHelper helper = new ConfigHelper();
	helper.setApplication(servlet.getServletContext());
	MessageResources messageResources = helper.getMessageResources();
	ActionErrors errors =
searchProductMasksForm.validate(actionMapping,request);
	if (errors !=null && !errors.isEmpty()) {
		Vector verr = new Vector();
		for(Iterator er = errors.get();er.hasNext();) {
			ActionError err = (ActionError)er.next();
			String message =
MessageResources.getMessageResources
("resources.application").getMessage(request.getLocale(),err.getKey(),err.ge
tValues());
			verr.add(message);
			if (log.isDebugEnabled()){
				log.debug("message="+message);
			}
		}
	}

S privetom,
Slava	
	
-----Original Message-----
From: Kornelis Sietsma [mailto:korny_lists@sietsma.com]
Sent: Wednesday, July 09, 2003 5:12 AM
To: struts-user@jakarta.apache.org
Subject: Converting an ActionError to a string programmatically


Hi all.

I am looking for a good way to turn an ActionError into a string, without
having a
PageContext or anything else so useful (so I can't use the
RequestUtils.message()
function).

Is there a simple way to do this?  I can probably do it the hard way, by
digging
through the RequestUtils source and working out what it does, but I'm hoping
that
either (a) there is another utility class I've missed that will do this, or
(b)
someone else has done this and can save me the pain!

The reason I need this is that I have some code that updates a back-end
system, and
returns ActionErrors if there are any validation failures.  Usually this
gets called
from a struts action, and the errors get displayed to the user with the
<errors/>
tag.

However, now we need to do some background batch updates, called from a
thread
spawned from a servlet (which is outside our normal struts pages).  The
batch process
is likely to be slow, and so we want the results of any validation failures
to get
logged to an error file, rather than getting displayed to the user.

Any suggestions?

- Korny
--
Kornelis Sietsma   http://www.sietsma.com/korny  korny@sietsma.com
goofey: korny  yahoo: kornysietsma  icq: 2039172 ph: 0421 079 693

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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message