1
votes

I'm trying to put an onClick event on a pager which is in a dataView. I want the onClick event to update a sessionScope variable. I've added the code and tested it, I can't get it to work. I made a test button and set it up with the same onClick event and the variable is updated correctly.

Right now, if I click the pager it works correctly and pages through the dataView. But, it doesn't update the sessionScope variable. Any ideas what could be causing this?

<xp:pager partialRefresh="true" id="pager8" xp:key="pagerBottomLeft"
                            styleClass="mblFooterLeft">
     <xp:this.rendered><![CDATA[#{javascript:isPagerDisplayed();
}]]></xp:this.rendered>

    <xp:pagerControl id="pagerControl2" type="Previous">

        <xp:eventHandler event="onclick" submit="true"
                 refreshMode="partial" refreshId="testLabel">
            <xp:this.action><![CDATA[#{javascript:incPagerDisplay(); 
                     sessionScope.pagerDisplay++;}]]></xp:this.action>
        </xp:eventHandler>

    </xp:pagerControl>
</xp:pager>

Any help would be greatly appreciated.

1
I am not sure this is problem with your code. It seems that events do not fire (client or server) from xp:pagerControl (reference link).Naveen

1 Answers

0
votes

While you're asking for an onClick event update to a sessionScope'd variable, it seems from your code that your end attempt is to save the page'd state the user is on, so they can navigate away/back and retain that from the sessionScope var. Assuming that's all you're trying to do with it, I recommend you check out and use the xe:pagerSaveState control.

Brad Balassaitis wrote a blog post on using it with a Data View, which may assist you. Oliver Busse tweaked that implementation a bit and demonstrates with his OSnippet; a massage to the SSJS call.

Here's Oliver's snippet:

<xe:pagerSaveState id="pagerSaveState1" refreshId="theView" partialRefresh="true">
</xe:pagerSaveState>

<xp:this.beforePageLoad><![CDATA[#{javascript:viewStateBean.restoreState = true;}]]></xp:this.beforePageLoad>