You need to sign in to do that
Don't have an account?
devendra dhaka
Visualforce page reload
I have written a vf page.
Initally I used normal HTML button, so it was working properly. But as per my functionality need I changed it to commandbutton. Now 'm calling a method using ACTION and simultaneously a onclick javascript method.
It first performs the javascript method and then does the action call.
The issue 'm facing that it reloads the page and all the javascript variable gets reinitialized.
How can I prevent that ??
I have to store the variables to their states.
Thanks in advance.
You should probably look at using a rerender attribute on your commandbutton - this turns the request into an ajax one, and you can rerender part of the page while keeping the rest of it (including javascript etc) as-is.
The other way to approach this would be to store the javascript values into the controller, but that probably complicates things.
I don't want to reload anything. I just want to call to controller. So shall I keep the reRender blank ??
I left the reRender blank and even assigned an id of some other element too. It has stopped refreshing the whole page.
But now my onClick event on the commandbutton is not responding ??
If you leave the rerender blank it will refresh the page, which doesn't sound quite what you are looking for. Rerender and onclick do co-exist together - I've used this a few times in the past. If you are having problems with that you might also consider using the onclick to execute your javascript and then hand off to an actionfunction with a rerender. That way you can use a regular HTML button.