I have a condition where the 开发者_如何学Gouser enters values in some fields in a form which is a popup.
This popup was achieved b using jquery..
My doubt here is when I validate the form and if the validation fails, I redirect the page to the same view..
return ModelAndView("xxx");
But I get the original xxx.jsp instead of the popup window...
Any sugestions for this ??
One way to achieve your requirement is to use ajax
to submit the data from the popup and return a JSON
response. The popup window can check the response and display suitable message therein, in case of error, or close itself in case of no errors.
Another way to do this is to have the original xxx.jsp have a javascript(jQuery) code which sets the flag in case of an error, and populates and opens popup. You'll have to pass the form values back to jsp in the model. Something like that:
<script>
//declare variable
var errorFlag=false;
</script>
//if you validate using validation
<spring:hasBindErrors name="xxx">
<script>
errorFlag=true;
</script>
</spring:hasBindErrors?
<script>
$document.ready(function(){
if (errorFlag) {
//open popup
}
}
);
</script>
精彩评论