Objective: When the user is trying to close a window, I need to check whether a particular list is empty or not. If its not empty, I need to make a hibernate call to do some action.
Did Coding as below: While the user is trying to close a window, I am calling a java script function closeWind() in jsp page.
In a separate java file, in a method checkListValue(), I am doing the logic of checking the list is empty or not, and making a hibernate call if its not empty.
Inside the javascript function closeWind(), I make a call to checkListValue() method using scriptlet tag.
My doubt here is, can I call the method checkListValue() using scriptlet tag inside the javascript function closeWind().
I tried this ,checkListValue() method is not getting called, but the alerts kept inside the java script function gets executed.
Pl help how to fix this issue.
Note: I did import the java file containing checkListValue() method in the jsp page
Hi,
You can't run Java code on Client side. That's why you can't use Java code in closeWind() Javascript function.
What you can do is:
a) Write Ajax code in the closeWind() function for calling a Servlet/JSP on the server side.
b) You can get the data into a variable through ajax call
c) based on the value returned you can execute the relevant JavaScript.
Check: Simple Ajax Example, Developing Simple Ajax application
Thanks
Thanks for your reply..
Thanks for your reply..