velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "White, Tim" <Tim.Wh...@qwest.com>
Subject Velocity Tools Error Question with Struts2
Date Thu, 17 Sep 2009 20:58:39 GMT
While my colleague is waiting to get added to this list, he asked me to post this question
on his behalf.

He is trying to access the error info from a Struts2 controller, and is having the issues
below:

Thanks,

Tim

I'm having trouble accessing the validationAware errors that are generated in an Action class.

GenericAction.java

declaration:
GenericLogin extends ActionSupport implements ServletRequestAware, ServletResponseAware, ServletContextAware,
ValidationAware

Code:
  addFieldError("ERROR_MSG_HEADER", "/qCmsRepository/Global/Messages/Errors/error.errorMessageHeader.vm");
  addFieldError("FIELD_TEST", "/qCmsRepository/Global/Messages/Errors/error.systemFailure.vm");



Velocity Tool

TestErrorTool.java

declaration:
TestErrorToolextends ActionSupport implements ValidationAware

if (hasFieldErrors())
{
      Map errorMap = getFieldErrors();
      String cmsErrorMessagePath = "";
      List fieldErrorList = (List)errorMap.get(errorKey);
      Iterator errorIterator = fieldErrorList.iterator();
      while (errorIterator.hasNext())
      {
           cmsErrorMessagePath = (String)errorIterator.next();
           System.out.println("ErrorKey: " + errorKey);
           System.out.println("ErrorMessagePath: " + cmsErrorMessagePath);
       }
}

I cannot access the validationAware object when I get to the Velocity Tool.
When you examie hasFieldErrors() it returns false.  When I look at the objects in debug mode,
the validationAware error, message & fieldErrors are NULL.

In the next step, the Interceptor, the validationAware objects are available again.

How do I get access to the ValidationAware objects that I set in the action class in the Velocity
Tool?

Any help is appreciated.


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