You need to sign in to do that
Don't have an account?

Close the VisaulForce Pop - UP windows In apex controller
Hello,
I have a custom button on a object which open a visual force page pop-up.
Can some body please help me or let me know. Is there any way I can close the window thorough the controller itself.
As I Do have validation in which if the data inserted is correct. The windows will close and save the data. And if the data is incorrect the class return a error message. If I write a Ajax close whenever the the call come back with message it close the window without showing the message.
Please help me and let me know if we can close the window in apex class (Controller) ???
You should use Ajax for this.
Why dont you use oncomplete in the VF tag you are invoking the controller.
In oncomplete, invoke the javascript function that will close the window based on the result you get from Controller.
All Answers
You should use Ajax for this.
Why dont you use oncomplete in the VF tag you are invoking the controller.
In oncomplete, invoke the javascript function that will close the window based on the result you get from Controller.
Thanks for your reply.
I am done with the problem i have used ajax and onstop i have called a javascript..
and also tried with what you said worked like a charm
thanks.
If you want a cheap way to do this without using the Ajax features, you can always just return a javascript function as the PageReference from the controller:
return new PageReference('javascript:window.close()');
Might seem silly, but it's effective!
Thanks Peter for sharing useful info with us.
Peter, I am getting the below error.
java.lang.IllegalArgumentException: Illegal view ID javascript:window.close(). The ID must begin with /
I got the same error.