Hello Matthias,
Thank you for your help.
The problem was indeed that I did not add poll-comp to the partial target.
Now I changed the listener as (it happens after navigation):
private class AccountPeriodRefreshCollectionListener implements
RefreshCollectionListener {
public DataPage refreshCollection(List<SortCriterion> sortCriteria,
int rangeStart, int rangeEnd) {
setInterval(1000);
RequestContext.getCurrentInstance().addPartialTarget(pollingComponent);
}
}
Another problem was that table was after the poll component in the jsp. So,
it did not work. I placed the poll component after the table:
<tr:table id="tr1" width="550" var="period"
partialTriggers="::pollBalances"
value="#{accountBean.accountPeriodsCollectionModel}" rows="25"
horizontalGridVisible="false" verticalGridVisible="true">
...
</tr:table>
<tr:poll pollListener="#{accountBean.onPoll}"
interval="#{accountBean.interval}" id="pollBalances" />
So, now first listener for the table is called, which also changed the
interval for the poll component. Then poll component is rendered and the new
value for the interval is picked up.
Great, it works after few days of struggling :)
Thanks a lot, Lena
Matthias Wessendorf-4 wrote:
>
> On Fri, Aug 7, 2009 at 10:45 AM, Lena Korshunova<[email protected]>
> wrote:
>>
>> Hello,
>>
>> I use polling for the table, but I do not need to poll all the time. So,
>> after I get information I need, I disable polling by setting polling
>> interval to a very big number. It works, but when I go to the next page
>> of
>> the table, I need to enable polling to get information for the new page.
>> I
>> tried to change polling interval, but it did not work. My jsp page is :
>>
>> <tr:poll pollListener="#{accountBean.onPoll}"
>> interval="1000"
>> id="pollBalances"/>
>> <tr:table width="550" var="period"
>> partialTriggers="::pollBalances"
>>
>> value="#{accountBean.accountPeriodsCollectionModel}" rows="25"
>> horizontalGridVisible="false"
>> verticalGridVisible="true">
>> ...
>> </tr:table>
>>
>> onPoll method where I disable polling is here:
>>
>> public void onPoll(PollEvent event) {
>> //get information I need and update table data model
>> ....
>> CorePoll pollingComponent = (CorePoll)event.getComponent();
>> pollingComponent.setInterval(10000000); //deactivate pooling, set
>> to
>> 2 hours
>>
>> }
>>
>> listener method, which is called when next page of the table is loaded:
>>
>> private class AccountPeriodRefreshCollectionListener implements
>> RefreshCollectionListener {
>>
>> public DataPage refreshCollection(List<SortCriterion>
>> sortCriteria,
>> int rangeStart, int rangeEnd) {
>> DataPage nextPage =
>> accountingService.getAccountPeriods(getAccountId(), sortCriteria,
>> rangeStart, rangeEnd);
>>
>> pollingComponent.setInterval(1000); //try to enable polling,
>> but
>> it does not work
>> }
>> }
>>
>> Could you, please, help me with some advice if you know how to solve this
>> problem?
>>
>> Thank you, Lena
>
>
>
> quick question:
>
> on your "listener" (after navigation, right?) have you added the poll-comp
> to the partial target ?
> => RequestContext.getCurrentInstance().addPartialTarget(comp);
>
> You may try to bind the interval number to a session scoped property;
> so in onPoll() you just access that; and add the poll to the partial
> target;
> after navigating your "listener" could just access the session scoped
> property again;
>
> -Matthias
>
>
>> --
>> View this message in context:
>> http://www.nabble.com/problem-with-disabling-polling-for-one-page-of-the-table-and-enabling-it-for-the-next-page-of-the-table-tp24861084p24861084.html
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Matthias Wessendorf
>
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
>
>
--
View this message in context:
http://www.nabble.com/problem-with-disabling-polling-for-one-page-of-the-table-and-enabling-it-for-the-next-page-of-the-table-tp24861084p24863435.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.