1

I need to catch the current page number of a view panel. I tried to grab for some property Pager component, but found none to return this value. Does anyone know how to get the value of the number of the current page.

I tried to apply the method indicated in the response of this post (Catching the Page Number), but clicking on a page in the pager of the error message The object does not support property or method 'addEventListenter' '

Community
  • 1
  • 1
Marcus Loza
  • 185
  • 8
  • My example you linked to works to this day. Go from there and add your changes piece by piece. – Knut Herrmann Oct 26 '16 at 20:56
  • I added the technique of his example in your code exactly is there, that is, put the event in the view panel, as example, however the error mentioned above occurs. By placing the event code Domino Designer is locked, however I decided through a custom control as Brad Balassaitis articles [article about event in view panel] (https://xcellerant.net/2013/01/14/viewpanel_onclientload/) and [article about event in custom control] (https://xcellerant.net/2013/07/10/fix-indenting-on-multiple-categories-in-a-view-panel/). – Marcus Loza Oct 27 '16 at 16:43
  • Add your example code to your question please. I am sure we can help you then. – Knut Herrmann Oct 27 '16 at 18:40
  • I took the code from your example and pasted in a XPage. What I could see is that if you do this on a local database and the code works, however the in the server can not even open the xpage in the designer. When trying to open crashes the designer. I tried to open the XPage both on a Domino server 8.5.3 and version 9.0.1. Anyway also tried to adapt it to an application and also did not get success, follows the XPage code. – Marcus Loza Oct 28 '16 at 11:57
  • The only difference is that I put the event on cost control as directly in XPage was catching my designer. In this case the error message 'The object does not support property or method 'addEventListenter' appears. – Marcus Loza Oct 28 '16 at 11:57
  • The code is in the first answer. – Marcus Loza Oct 28 '16 at 12:04

2 Answers2

0
<!-- language: lang-js -->
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
    xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xc="http://www.ibm.com/xsp/custom">

    <xp:viewPanel
        rows="30"
        id="viewPanel1">
        <xp:this.facets>
            <xp:pager
                partialRefresh="true"
                layout="Previous Group Next"
                xp:key="headerPager"
                id="pager1">
            </xp:pager>
            <xc:ccPegaPagina xp:key="south" />
        </xp:this.facets>
        <xp:this.data>
            <xp:dominoView
                var="view1"
                databaseName="xxxx.nsf"
                viewName="vi_xxxx">
            </xp:dominoView>
        </xp:this.data>
        <xp:viewColumn
            columnName="nm_xxxx"
            id="viewColumn1">
            <xp:viewColumnHeader
                value="Nome xxxxx"
                id="viewColumnHeader1">
            </xp:viewColumnHeader>
        </xp:viewColumn>
        <xp:viewColumn
            columnName="Fonexxx"
            id="viewColumn2">
            <xp:viewColumnHeader
                value="Tel. xxx"
                id="viewColumnHeader2">
            </xp:viewColumnHeader>
        </xp:viewColumn>
        <xp:viewColumn
            columnName="celular xxx"
            id="viewColumn3">
            <xp:viewColumnHeader
                value="Celular particular xxx"
                id="viewColumnHeader3">
            </xp:viewColumnHeader>
        </xp:viewColumn>
        <xp:viewColumn
            columnName="FoneResidencial xxx"
            id="viewColumn4">
            <xp:viewColumnHeader
                value="Tel Residencial xxxx"
                id="viewColumnHeader4">
            </xp:viewColumnHeader>
        </xp:viewColumn>
    </xp:viewPanel>
</xp:view>

The custom control:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:eventHandler
        event="onClientLoad"
        submit="false">
        <xp:this.script><![CDATA[ dojo.query('[id$=pager1] a').forEach(function(entry) {
                entry.addEventListener("click", function() {
                    alert(this.innerHTML);
                });
            });]]></xp:this.script>
    </xp:eventHandler></xp:view>
Marcus Loza
  • 185
  • 8
0

I took your code and just changed it a bit so it shows names.nsf's view ($Users) so everyone can test it. It works.

I set different themes like "webstandard", "OneUI", "OneUI V3.0.2" and "Bootstrap3" - all work fine.

enter image description here

XPage:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom">
    <xp:viewPanel rows="3" id="viewPanel1">
        <xp:this.facets>
            <xp:pager partialRefresh="true" layout="Previous Group Next"
                xp:key="headerPager" id="pager1">
            </xp:pager>
            <xc:ccPegaPagina xp:key="south" />
        </xp:this.facets>
        <xp:this.data>
            <xp:dominoView var="view1" databaseName="names.nsf"
                viewName="($Users)">
            </xp:dominoView>
        </xp:this.data>
        <xp:viewColumn columnName="FullName" id="viewColumn5">
            <xp:this.facets>
                <xp:viewColumnHeader value="Full name" xp:key="header"
                    id="viewColumnHeader5">
                </xp:viewColumnHeader>
            </xp:this.facets>
        </xp:viewColumn>
    </xp:viewPanel>
</xp:view>

Custom control "ccPegaPagina":

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:eventHandler event="onClientLoad" submit="false">
        <xp:this.script><![CDATA[ dojo.query('[id$=pager1] a').forEach(function(entry) {
                entry.addEventListener("click", function() {
                    alert(this.innerHTML);
                });
            });]]></xp:this.script>
    </xp:eventHandler>
</xp:view>

Put the code into a new database without any property changes and test it. If this works go from there.

Update

As we figured out in comments it doesn't work in IE 7 and 8.
The same applies for IE 11 with compatibility mode 7 and 8.
This is normal as addEventListener was first available in IE 9.
So, this solution needs at least IE 9 or any other modern browser.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • Hello Knut! It's unbelievable! I did the following: I created a new base. I took your code is pasted on an XPage and also pasted the custom control. Tests made in the following scenarios: Local: the code worked, as I have already noted hereinbefore. In a version 8.5.3 server: The same error was cited already displayed. In a version 9.0.1 server: The same error was cited already displayed. The only detail that I do not think I quoted is that I am doing these impementations in Domino Designer 9.0.1. Grateful for your patience! – Marcus Loza Oct 31 '16 at 17:32
  • Which browser/version do you use? – Knut Herrmann Oct 31 '16 at 18:08
  • Here is the problem! The browser approved by the company to be used is IE version 11. I tested the Chrome worked! The question is, why it works with local base in IE and server gives the error? – Marcus Loza Oct 31 '16 at 18:16
  • That's because you've activated compatibility mode in IE and set document mode to 7 or 8. From 9 on it does work. – Knut Herrmann Oct 31 '16 at 18:42
  • You shined! The problem is IE. This makes the incompatible solution. I'll try another way to get the page number. Danke! – Marcus Loza Nov 01 '16 at 10:52
  • Do you really need this old IE version 7 or 8? It would work from IE 9... – Knut Herrmann Nov 01 '16 at 10:55
  • What can realize is that the Domino environment applications are running in compatibility mode 7. Is there a way to force the run in compatibility mode 9-level server or Domino environment? Checked in [Article] (http://www.intec.co.uk/compatibility-mode-what-any-xpages-or-web-developer-needs-to-know/) Paul Withers there as force mode the level of application compatibility, but this is not ideal. I applied this feature example of XPage and it worked. – Marcus Loza Nov 01 '16 at 11:55
  • Did you try `response.setHeader("X-UA-Compatible", "IE=9");` https://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx ? – Knut Herrmann Nov 01 '16 at 12:12
  • Yes, I tried, but this method is the application level. There is no way to apply this compatibility mode to the Domino environment as a whole, or at least the level of Domino server? – Marcus Loza Nov 01 '16 at 12:30
  • I don't know if it's possible to set it for whole Domino server but to set it on application level seems appropriate to me as the setting is connected to used code (like CSJS code with .addEventListener in this case). So, every developer can decide for application which mode to set. – Knut Herrmann Nov 01 '16 at 12:59
  • Thanks a lot Knut! – Marcus Loza Nov 01 '16 at 13:17