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:
Please check the following
In your struts.xml edit the following
And in your js code edit the below.
Edit in your JSP instead of the following,
use
and add below line in you js code
to check the result name
if your method signature like below,
You can get the data in your js code as below,