You need to sign in to do that
Don't have an account?
rerender doesn't work on actionFunction when actionFunction called from commandButton
function doItWrapper() { // alert("in doItWrapper()"); doItFunc(); } ... <apex:actionFunction name="doItFunc" action="{!doItInner}" rerender="resultPanel"/> ... Change Me: <input type="text" id="fname" onchange="doItWrapper()"/> ... <apex:commandButton value="Do It Wrapper" onClick="doItWrapper();" />
Relavent portion of code above.
I find that when the commandButton is pressed, the doItWrapper() function is execute which in turns executes the doItFunc actionFunction. The actionFunction does call the server. But, the rerender doesn't happen, resultPanel is an outputPanel and its contents do not change.
When I change the value in the field labelled "Change me", it works fine. doItWrapper() is called; the actionFunction is called which calls the server; and then the panel is rerendered just fine.
Anyone know why the rerender doesn't work when the script is invoked from commandButton but is when invoked from an input field?
One of our developers tried to resolve this issue by also putting a rerender attribute on the command button.
That looks to have caused a very serious issue that took a long time to debug. The button then did two AJAX requests, one from the script and one because of the rerender. The page worked correctly about four out of five times, but one out of five times some items in view state were lost and the page broke. I suspect the randomness was the result of a race condition in that depending on which request returned first, you got one of the two behaviors.
I believe the fix is definitely not also including a rerender on the commandButton tag.
Hi Ken,
Is commandButton click refreshing your page ?
If yes, try to call the javascript fucntion like this:
Click Kudos(star icon on left) if this provides you with useful information and mark it as a solution if it solves your problem.
Actually, it's the opposite problem. The rerender on the actionFunction doesn't refresh the contents.
But wha you said will only work with action= on commandButton. It doesn't work with rerender= on commandButton.
If you call an onClick() function on commandButton, regardless of what it returns, it will do a server interaction if it has a rerender on it.
I took a look at the generaed JS code in this situation. There's no conditional. It calls my JS function, then does the AJAX request.