Thursday, December 10, 2009

Struts2 ActionErrors not being cleared Validation error messages

phew!

This is one of the hardest problems I've ever faced. The sad part it it does not deserve to be there.

 If the action errors or error messages that you are adding for validation purposes or error indication purposes are not getting cleared, this solution may just get you out of the hole. This is valid only if you are using Spring with Struts2


Solution:

In the action class's Spring configuration make the scope as prototype for Action classes! If Action classes are Singleton which by default the instantiation mode in Spring, error messages stick to the action and you will never get rid of it. You've got problems with that behaviour? Ask the Workflow interceptor.

One of the banes of working on a framework with a beginner's/intermediate knowledge.

No comments:

Post a Comment