javavalidationjspstruts2struts2-jquery

sj:submit with targets and errorElementId not rendering properly


I have a struts application, In one of the pages I am using sj:submit to submit the page with targets and errorElementId attributes.I have used the Struts2 validations on the page and the result type are written so that the success will redirect to a div and the failure will redirect the action to the same div, using errorElementId like the following

<div id="errorDiv" >
<sj:submit targets="successDiv" errorElementDiv="errorDiv" />
</div>
<div id="successDiv">
</div>

On testing this page I am getting the success response to the successDiv as given in the targets attribute, but in case of validation errors I am expecting the page to return to the same div where the sj belongs ie the errorDiv , but then also the the page with validation errors are rendered in the successDiv like the following

enter image description here

the result types for the action are the following

<result name="success">jsp/process/processlist.jsp</result>
            <result name="input">jsp/process/addprocess.jsp</result>

Can somebody tell me where I am going wrong.


Solution

  • This worked for me . It uses a an interceptor called jsonValidationWorkflowStack , which will return the validation errors , which are handled by javascript .