2

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.

James McMahon
  • 48,506
  • 64
  • 207
  • 283

1 Answers1

2

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>
Andrey
  • 6,526
  • 3
  • 39
  • 58
  • This is useful for internal changes inside the table, datascroller, and basically anything on the page you can put in the a4j:region but for request coming from modals or other pages that update the table you need to do a separate status. – James McMahon Oct 03 '11 at 14:54
  • @James McMahon Can you describe a use case in the question? As I understand you need loading message even for GET requests (first page layout is displayed with Loading.. message, then table content (separate 'lazy' AJAX request to server?)). – Andrey Oct 04 '11 at 18:12
  • @James McMahon That first method obviously is not about lazy loading. I have updated my answer with lazy loading solution. That solution uses some JBoss Seam features (page scope and method invocation with parameters in EL), I believe you will manage to do the same using just JSF 1.2 (e.g. functions for EL, and session scope or request scope+hidden fields instead of page scope). – Andrey Oct 05 '11 at 15:59
  • Thank you for the detailed answer. I will have to try this out. – James McMahon Oct 05 '11 at 22:44