I have in my action class:
try{
tspNameIdMap = slsReqMgmtCommonRemote.getTspNameIdMap(Integer.parseInt(circleId));
throw new ReqMgmtException("Message test");
}
catch(ReqMgmtException rEx){
addActionError("Action-Error: Request Management Exception thrown");
return ERROR;
}
I am doing an AJAX call and using Struts2-Json-plugin to get tspNameIdMap
in JSON form.
JS: Part of AJAX:
success: function(data){
alert('Updated DB');
},
error: function(data){
alert(data);
}
My struts.xml
:
<action name="findTspNameIdMap"
class="cdot.oss.cmsat.gma.struts.ConfigureTspThresholdAction" method="findTspNameIdMap">
<result name="success" type="json">
<param name="root">
tspNameIdMap <!-- tspNameIdMap will be returned in JSON form -->
</param>
</result>
</action>
I want my addActionError
message in my Ajax error function. I will also want to display it in my JSP then. How can I get this?
Ps: Do I have to include this ActionError message in a properties file? I am using it for first time. Help
EDIT : As i followed @Prabhakar answer I got the error message, but it got returned in the success
of the AJAX call.
Another issue is that, when i put this in my JSP, the actionerror
is not getting displayed.
Jsp:
<s:if test="hasActionErrors()">
<s:actionerror />
</s:if>
You can configure result
ERROR
to return the rendered error page fragment to the Ajax response.error.jspx: