Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...



Q. How do I change the error message for invalid inputted fields?
A: You need to create a message for that field, for example if you have a user.dob field you would use this in your messages file (see above for example on setting a global messages file):
invalid.fieldvalue.user.dob=Please enter Date of Birth in the correct format.

Q. How do I get access to the Session?
A: ActionContext.getContext().getSession() (returns Map, works internally using a ThreadLocal)

Q. How can I see all parameters passed into the Action?
A: ActionContext.getParameters() (returns Map, works internally using a ThreadLocal)

Q. How can I get the HttpServletRequest?
A: ServletActionContext.getRequest() (works internally using a ThreadLocal)

Q: How can I use the IOC container to initialize a component in another object that isnt an action?
A: obtain the ComponentManager from the request: ComponentManager cm = (ComponentManager) ServletActionContext.getRequest().getAttribute("DefaultComponentManager");
then you need to initialize it using: cm.initializeObject(Object)

Q. How do I decouple XWork LocalizedTextUtil global resource bundle loading from serlvets (ServletContextListener)?

...