i have override validate method and added errors using
addFieldError("test", "test print");
and in jsp used
<s:fielderror />
but the errors are not displayed in input.jsp.
Also my jsp content type is
<%@ page contentType="text/html; charset=UTF-8"%>
My struts.xml is like
<action name="test" class="ListInfo">
<result>/input.jsp</result>
</action>
<action name="Proceed" class="Details">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="execAndWait">
<param name="delay">100</param>
</interceptor-ref>
<result name="wait">Wait.jsp</result>
<result name="success">/Summary.jsp</result>
<result name="input" type="chain">test</result>
<result name="failure" type="chain">test</result>
</action>
Turns out that errors (field and action are NOT maintained across a chain.
Following proves this (assumes struts2-conventions-plugin-VERSION):
Action foo always chains to action bar (so we only need a view for action bar)
Action foo
Action bar
view for bar: /WEB-INF/content/bar.jsp
Testing the above we see nothing show up in the errors.
To fix the issue we use the store interceptor: http://struts.apache.org/2.0.14/struts2-core/apidocs/org/apache/struts2/interceptor/MessageStoreInterceptor.html
In the first action (#1) we will need to add annotations and the imports to support them:
In the second action (#2) we will need to add annotations and the imports to support them:
And now it works.