Question

Has anyone found a way of display a loading message while rich:dataTable loads?

I've found that if the load operations backing DataModel takes along time it results in the request taking along time. Is the an effective way of display a message to the user during this load?

I'm using Richfaces 3.3.3.

Was it helpful?

Solution

You can use a4j:status. Refer to Exadel livedemo for more details: http://livedemo.exadel.com/richfaces-demo/richfaces/status.jsf?c=status&tab=usage

If you need to show messages on data table interactions only, you can limit area for a4j:status by a4j:region:

<a4j:region>
    <a4j:status startText="Loading. Please wait..." >

    <rich:dataTable .../>
</a4j:region>

UPDATE: For lazy loading of some content, the following approach can be used. Create a facelet (or component):

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:c="http://java.sun.com/jstl/core"
            xmlns:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich">
<h:panelGroup id="lazyP#{id}" layout="block">
    <ui:fragment rendered="#{lazy.isRendered(id)}">
        <ui:insert name="lazy"/>
    </ui:fragment>
    <ui:fragment rendered="#{not lazy.isRendered(id)}">

        <h:outputText value="Loading..."/>

        <a4j:region>
            <a4j:jsFunction name="loadData#{id}" reRender="lazyP#{id}"
                            action="#{lazy.release(id)}"
                            limitToList="true"
                            ajaxSingle="true" eventsQueue="lazyQueue"/>
        </a4j:region>
        <script type="text/javascript">
            jQuery(document).ready(function() {
                loadData#{id}();
            });
        </script>
    </ui:fragment>
</h:panelGroup>

lazy is reference of bean (I use page scope) which stores map of what was rendered and what was not (release method marks item as rendered).

Then you can use that like the following:

<ui:decorate template="lazyLoad.xhtml">
     <ui:param name="id" value="someId"/>
     <ui:define name="lazy">
           <rich:dataTable ... />
     </ui:define>
</ui:decorate>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top