Reputation: 189
I have a condition where the user 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 ??
Upvotes: 0
Views: 1246
Reputation: 8067
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>
Upvotes: 0
Reputation: 52665
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.
Upvotes: 1