You need to sign in to do that
Don't have an account?
Arvind1
Using actionpoller for commandbutton
Hi All,
I have a requirement where the record should be saved 5 seconds after the click of a button.
I know that there is an actionpoller function in which I can give the time interval to perform the action.
But I am not getting the syntax how to use actionpoller with commandbutton.
Any suggestion on this will be of a great help.
Thanks
Arvind
I reckon you'd want something like:
<apex:actionFunction name="doSubmit" action="{!doSubmit}"/> <apex:commandButton value="Submit" onclick="setTimeout('doSubmit();', 5000); return false;"/>
All Answers
ActionPoller is more for regular periodic updates - e.g. I use this in a monitoring solution to refresh the values every 'n' minutes.
It may be possible to do this by having the action method tied to the command button set a value in the controller (e.g. showpoller set to true), then have an outputpanel containing the actionpoller only rendered if showpoller is true. I haven't tried this though - it feels a bit clunky to me.
I'd be inclined to create an actionfunction that ties your save method to a javascript function, and then set the onclick attribute of the commandbutton to something like "setTimeout(your_action_function, 5000)" - that way you are using vanilla javascript and limiting the round trips to the server.
Hi Bob,
Thanks for the reply.
Could you please give a sample code for this as I am not that much comfortable in javascript.
Thanks
Arvind
I reckon you'd want something like:
<apex:actionFunction name="doSubmit" action="{!doSubmit}"/> <apex:commandButton value="Submit" onclick="setTimeout('doSubmit();', 5000); return false;"/>