Theme
Waypoint
Infinite scrolling with p:remoteCommand and offset as function. The offset defines a waypoint if the bottom of the element is in view. When resizing the window, this offset will be recalculated automatically. The Waypoint component self is used in combination with pe:javascript. In the callback function we check the current scrolling direction. Furthermore, we use two widget methods: disable() and enable(). The method disable() temporarily disables the waypoint (callback function) from firing, but leaves the waypoint's event bound. Calling enable() again in the future would re-enables a previously disabled waypoint and the old handlers would continue to work.
Source

<h:panelGroup id="wrapper" layout="block">
    <h1>Infinite scrolling with Waypoint</h1>
    
    <h:panelGroup id="container" layout="block">
        <div class="article">
            <h2>Lorem Ipsum Dolor</h2>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
               Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero
               sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. 
               Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, 
               commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, 
               eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar 
               facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, 
               eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan 
               porttitor, facilisis luctus, metus xyx rtel supepr sey reror.</p>
        </div>
        <div class="article">
            <h2>Sit Amet</h2>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. 
               Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero 
               sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
               Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. 
               Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero 
               sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. 
               Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero 
               sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
               Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. 
               Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero 
               sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
        </div>
        <div class="article">
            <h2>Consectetuer Adipiscing Elit</h2>
            <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
               Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed.
               Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
               Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed.
               Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
               Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed.
               Test Consectetuer Adipiscing Elit, consectetuer elit, consectetuer adipiscing.</p>
        </div>
        <div class="article">
            <h2>Aenean</h2>
            <p>Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum
               vulputate, nunc, cbuiewe dyxyxew Assdle upsula quite dsenda webald, Aksuid sind luidd svbnm
               yxcdqw el ijghfdf dklioe otvet nam sendrt Klimprt, second third aplogi beret treidsd ne.
               Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, 
               commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum.</p>
            <p>Aliquam tincidunt mauris eu risus. Donec consectetuer ligula vulputate sem tristique cursus.
               Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate
               sem tristique. Waypoint eu vulputate magna eros eu erat. Aliquam erat volutpat.
               Aliquam tincidunt mauris eu risus. Donec consectetuer ligula vulputate sem tristique cursus.
               Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate
               sem tristique. Waypoint eu vulputate magna eros eu erat. Aliquam erat volutpat.</p>
        </div>
        <div class="article">
            <h2>Vestibulum</h2>
            <p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros
               eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus,
               metus sit amet est et sapien ullamcorper pharetra. Aliquam erat volutpat. Nam dui mi, tincidunt
               quis, accumsan porttitor, facilisis luctus. Hello said dkrew qwq ncki juewewe, upsum el.</p>
            <p>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem
               tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi tri ssev.
               Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem
               tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi tri elektron.
               Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem
               tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</p>
        </div>
    </h:panelGroup>
    
    <h:panelGroup id="remoteContent" style="display:none;">
        <ui:include src="#{infiniteScrollController.src}"/>
    </h:panelGroup>        
    
    <p:remoteCommand id="rcom" name="loadRemoteContent" process="@this" update="remoteContent"
                     actionListener="#{infiniteScrollController.toggleSrc}"
                     oncomplete="handleLoadStop()"/>
    
    <p:dialog widgetVar="loadingDlg" resizable="false" showHeader="false">
        <h:panelGrid columns="2">
            <h:graphicImage library="images" name="ajax-loader1.gif"  
                            style="margin-right: 12px; vertical-align: middle;"/>  
            <h:outputText value="Content is loading..." style="white-space: nowrap;"/>
        </h:panelGrid>
    </p:dialog>

    <h:panelGroup id="footer" layout="block">
        <p:separator/>
        Copyright, PrimeFaces Extensions, 2013.
        
        <pe:waypoint id="waypoint" widgetVar="waypointWidget"
                     offset="function(){return $.waypoints('viewportHeight') - $(this).outerHeight()}">
            <pe:javascript event="reached" execute="handleLoadStart(ext);"/>
        </pe:waypoint>
    </h:panelGroup>
</h:panelGroup>

<h:outputScript id="waypointScript" target="body">
/* <![CDATA[ */
    function handleLoadStart(ext) {
        if (ext.direction == "down") {
            PF('waypointWidget').disable();
            PF('loadingDlg').show();
            loadRemoteContent();
        }
    }
    
    function handleLoadStop() {
        $('#container').append($('#remoteContent > div.article'));
        PF('loadingDlg').hide();
        PF('waypointWidget').enable();
    }
/* ]]> */
</h:outputScript>

=== first remote content from the file remoteContentOne.xhmtl (for demo purpose)
                
<div class="article">
    <h2>Vestibulum One</h2>
    <p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros
        eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus,
        metus sit amet est et sapien ullamcorper pharetra. Aliquam erat volutpat. Nam dui mi, tincidunt
        quis, accumsan porttitor, facilisis luctus. Hello said dkrew qwq ncki juewewe, upsum el.
        tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi zuuiui gf.</p>
    <p>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem
        tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi tri ssev.
        Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem
        tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi tri elektron.
        Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem
        tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</p>
</div>
                
=== second remote content from the file remoteContentSecond.xhmtl (for demo purpose)
                
<div class="article">
    <h2>Vestibulum Second</h2>
    <p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros
        eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus,
        metus sit amet est et sapien ullamcorper pharetra. Aliquam erat volutpat. Nam dui mi, tincidunt
        quis, accumsan porttitor, facilisis luctus. Hello said dkrew qwq ncki juewewe, upsum el.
        tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi zuuiui gf.</p>
    <p>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem
        tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi tri ssev.
        Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem
        tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi tri elektron.
        Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem
        tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</p>
</div>
            
Components and more
Documentation pe:waypoint
Attributes (move mouse over the names to see data types)
Name Description
id Unique identifier of the component in a namingContainer.
rendered Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar Name of the client side widget.
for The target component registered as waypoint. If null, the parent component will be taken as target. Default is null.
forContext The context defines which scrollable element the waypoint belongs to and acts within. It can be a component or plain HTML element like a div. Default is window if nothing specified.
enabled If false, this waypoint will be created but will be disabled from triggering. You can call widget's method "enable" to turn it back on. Default is true.
horizontal Default waypoints live on the vertical axis. Their offset is calculated in relation to the top of the viewport and they listen for vertical scroll changes. If horizontal is set to true, offset is calculated in relation to the left of the viewport and listens for horizontal scroll changes. For instance, the value 50 means "when the left side of this element reaches 50px from the left side of the viewport". Default is false.
offset This option determines how far the top of the element must be from the top of the viewport to trigger a waypoint (callback function). It can be a number, which is taken as a number of pixels (can be also negativ, e.g. -10), a string representing a percentage of the viewport height (e.g. '50%') or a function that will return a number of pixels. Default is 0.
continuous If true, and multiple waypoints are triggered in one scroll, this waypoint will trigger even if it is not the last waypoint reached. If false, it will only trigger if it is the last waypoint. Default is true.
triggerOnce If true, the waypoint will be destroyed when triggered. Default is false.
Events (move mouse over the names to see classes)
Name Description
reachedfired when the user scrolls past the element.
PrimeFaces Extensions Showcase - © 2011-2021,PrimeFaces: 11.0.0,PrimeFaces Extensions: 11.0.0,JSF: Apache MyFaces JSF-2.3 Core API 2.3.9,Server: jetty/9.4.36.v20210114,Build time: 2021-12-10 14:32
occured!