0

Have the following issue: there is p:remoteCommand that lazy loads p:dataTable after page load, but the load indicator of "p:ajaxStatus" is not shown during the time of the ajax request...

How to make "p:ajaxStatus" to be shown on the page when p:remoteCommand sends request for lazy loading of the data?

Code on the page:

<h:form id="form">

    <p:remoteCommand name="loadLazyData" action="#{crmBackingBean.crmOnControlLazyInit}" autoRun="true" process="@this" update="dtCrmOnControl" />

    <p:dataTable id="dtCrmOnControl" var="rowData" value="#{crmBackingBean.crmOnControlLazy}" widgetVar="dtCrmOnControl" rows="#{crmBackingBean.crmDTonControlRows}" paginator="true" ..... lazy="true" >
        .......................................................
    </p:dataTable>

</h:form>

I use Atlas theme, p:ajaxStatus is located in its original place, in template.xhtml:

<p:ajaxStatus style="width:40px; height:40px; position:fixed; right:30px; bottom:30px; z-index:999999;">
    <f:facet name="start">
        <i class="fa fa-circle-o-notch fa-spin Green Fs40"></i>
    </f:facet>
    <f:facet name="complete">
        <h:outputText value="" />
    </f:facet>
</p:ajaxStatus>

Thank you!

Versions: PrimeFaces 6.0.2; PrimeFaces Atlas Theme 1.1.1; GlassFish 4.1.1 with JSF 2.2.12 (Mojarra)

AndrewG10i
  • 661
  • 1
  • 6
  • 21
  • does it work if you use `` and manually click on the button? Does it work if you use the `` inside the same form? – Kukeltje Aug 09 '16 at 12:14
  • @Kukeltje, thank you, the `` works, and actually it made me able to find the solution: I use standard PrimeFaces Atlas theme, and its standard template contains `` tag after ``, thus obviously ajaxStatus just simply doesn't "hear" "remoteCommand" as it loaded after remoteCommand (actually not sure whether it is bug or feature...) So basically my fix was just to move `` above and put it as first tag after ` ` [code](http://forum.primefaces.org/viewtopic.php?f=3&t=46591) – AndrewG10i Aug 11 '16 at 11:41
  • Please create this as an answer, but make sure you add the right version info to both the question and answer! And please file a bug in the PF issuelist. If it is not a bug, it should at least be documented! – Kukeltje Aug 11 '16 at 12:27

2 Answers2

1

The solutions is following:

The tag <p:ajaxStatus> should be placed on the xhtml source page BEFORE tag <p:remoteCommand>.

Environment:

  • PrimeFaces 6.0.2
  • PrimeFaces Atlas Theme 1.1.1
  • GlassFish 4.1.1 with JSF 2.2.12 (Mojarra)
AndrewG10i
  • 661
  • 1
  • 6
  • 21
-1

it seems like you've missed a few essential defintions. How should your status notice that there is any action going on? Also, I suppose you'd like to display a dialog during waiting and configure its styling in ajaxStatus, is that correct?

If so, I recommend you to create an own dialog by <p:dialog> and add the onstart and onsuccess attributes to your ajaxStatus as described in Primefaces showcase: http://www.primefaces.org/showcase/ui/ajax/status.xhtml

It will be something like

<p:ajaxStatus onstart="PF('statusDialog').show()" onsuccess="PF('statusDialog').hide()" />

<p:dialog widgetVar="statusDialog" modal="true" draggable="false" closable="false" resizable="false" showHeader="false">
    <p:graphicImage name="waiting_picture.gif" />
</p:dialog>

You can easily combine this solution with a datatable / paginator.

I hope this helps!

EDIT: Why don't you define the rows per page to support lazy loading? http://www.primefaces.org/showcase/ui/data/datatable/paginator.xhtml

EDIT 2: You can also call your loadLazyData method on start:

<p:ajaxStatus onstart="loadLazyData" />

or something like this...

  • 1: _"How should your status notice that there is any action going on?"_ No, the docs state: **"AjaxStatus is a global indicator to provide feedback about the ongoing ajax request. "** 2: _"Also, I suppose you'd like to display a dialog during waiting and configure its styling in ajaxStatus, is that correct?"_ Not needed only if you explicitly want to.. – Kukeltje Aug 09 '16 at 10:52
  • _"EDIT: Why don't you define the rows per page to support lazy loading?"_ it still not loads it after the basic page load, but during... _"EDIT 2: You can also call your loadLazyData method on start:"_ So you want to (re)load the data on EACH ajax call of every component on the page? I would not think so. – Kukeltje Aug 09 '16 at 10:53
  • chaeschuechli, thank you for your post! ...the only issue that I am looking for a little bit different solution... Re raised questions - I absolutely agree with Kukeltje comments. – AndrewG10i Aug 11 '16 at 11:24