-
1. Re: Cancelling an a4j:poll
bkersten Feb 23, 2010 6:10 AM (in response to tnaran)1 of 1 people found this helpfulThe poll once actived causes a JS based timer to send AJAX requests continously (concurrent to user AJAX requests). A tab switch (ajax switch mode) does not destroy the JS timer, but additional AJAX requests might be send (by the poll) before your user AJAX request (tab switch) is completed. This might cause a few more poll-ajax-requests after tab change or concurrent to it resp. (depending on interval settings and response time of tab switch). I think this is still the official/recommended way to stop polling (i.e. set pollFlag to false with tab change and reRender the poll-component).
If u need to stop polling immediately with the tab change u might want to consider to call A4J.AJAX.StopPolling( pollComponentClientId ) to unregister the timer per JS. This is probably not the "official way", i.e. i don't know about future JS API changes or compatibility to your code, but it worked in the sample below:
<a4j:region id="region"> <h:form id="pollForm"> <a4j:poll id="poll" interval="500" enabled="#{TestBean.pollEnabled}" reRender="poll,panel" /> </h:form> </a4j:region> <h:form> <rich:tabPanel switchType="ajax" ontabchange="A4J.AJAX.StopPoll('pollForm:poll');"> <rich:tab label="tabPoll"> <a4j:outputPanel id="panel"> <h:outputText id="pollValue" value="#{TestBean.currentDate}" /> </a4j:outputPanel> </rich:tab> <rich:tab label="tab2nd"> <h:outputText value="test"/> </rich:tab> </rich:tabPanel> </h:form> <h:form> <a4j:commandButton style="width:120px" id="control" value="#{TestBean.pollEnabled?'Stop':'Start'} Polling" reRender="control, poll, panel"> <a4j:actionparam name="polling" value="#{!TestBean.pollEnabled}" assignTo="#{TestBean.pollEnabled}" /> </a4j:commandButton> </h:form>
In addititon to that: i think it is not recommended to put the poll component into a form of the tab panel together with different components, as all values will be transmitted with each poll (cp. hints at http://livedemo.exadel.com/richfaces-demo/richfaces/poll.jsf;c=poll&tab=usage ). Instead, usage of a seperate form/region as above should be preferable.
-
2. Re: Cancelling an a4j:poll
ilya_shaikovsky Feb 24, 2010 5:42 AM (in response to bkersten)thanks! It's could be used but undocumented so added the point to FAQ. http://community.jboss.org/wiki/AjaxCoreComponents
-
3. Re: Cancelling an a4j:poll
nimo22 Feb 24, 2010 1:52 PM (in response to ilya_shaikovsky)So I assume, that there also exists the JS-Method:
A4J.AJAX.StartPoll
Where can I find all the Java-Script A4J-or Richfaces Methods such as
A4J.AJAX.StopPoll
A4J.AJAX.StopPush
or
Richfaces.hideModalPanel
Richfaces.showModalPanel
or
...Does Richfaces has a Java-Script-API ?
Where can I find it?
If not, where can I find the JS-sources (in rf-api, rf-impl or rf-ui), so I can grab the methods out of it?
-
4. Re: Cancelling an a4j:poll
ilya_shaikovsky Feb 25, 2010 6:56 AM (in response to nimo22)Yes start methods like you mentioned also exist.
Unfortunatelly we didn't caried about public JS API from the beggining. So the components created since 3.2.x - has them in documentation and older components not. So if you can't find api in documentation - unfortunatelly you will need to check js on your own. Them could be find at:
richfaces-ui-3.3.3-SNAPSHOT.jar\org\richfaces\renderkit\html\script\
and
richfaces-ui-3.3.3-SNAPSHOT.jar\org\richfaces\renderkit\html\script\
3.3.x branch will not be changed significantly in the future as it's under stabilization works only so you could safelly use any of the components methods which need.
And good news - we will care about that in 4.x from the beggining for every component.
-
5. Re: Cancelling an a4j:poll
nimo22 Feb 25, 2010 9:58 AM (in response to ilya_shaikovsky)I am looking forward in using RF 4
I click "A4J.AJAX.StopPoll" - it stops polling.
After it stops, I click "A4J.AJAX.StartPoll" but it does not start the poll again, why?
{code}
<a4j:region>
<h:form id="form_view_progress">
<a4j:poll id="poll"interval="1000"
enabled="true"
reRender="poll_region"
limitToList="true"
ajaxSingle="true"
ignoreDupResponses="true"/>
</h:form>
</a4j:region>
<h:form>
<a4j:commandButton value="start poll" onclick="A4J.AJAX.StartPoll('my_form:poll');"/>
<a4j:commandButton value="stop poll" onclick="A4J.AJAX.StopPoll('my_form:poll');"/></h:form>
{code}
What is the name of the *.js-script?
Cannot find a "poll.js"
in richfaces-ui-3.3.3-SNAPSHOT.jar\org\richfaces\renderkit\html\script\ or
richfaces-ui-3.3.3-SNAPSHOT.jar\org\richfaces\renderkit\html\scripts\,
-
6. Re: Cancelling an a4j:poll
ilya_shaikovsky Feb 25, 2010 10:10 AM (in response to nimo22)seems I just looked to some wrong place found some start functions and decided that them are defined for poll unfortunatelly there are no such methods. But if you need to just start polling after tab actually changed - just reRender it from tab so it will be re-initialized and started.
-
7. Re: Cancelling an a4j:poll
nimo22 Feb 25, 2010 10:34 AM (in response to ilya_shaikovsky)okay thanks, have done that.