<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to create a loading indicator in a HTML user dialog?</title><link>https://answers.axonivy.com/questions/14/how-to-create-a-loading-indicator-in-a-html-user-dialog</link><description>&lt;p&gt;I need to give my users a visual feedback when I load/save something so that they know the system is still working. How can I easily create such a feedback?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/14/how-to-create-a-loading-indicator-in-a-html-user-dialog" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 07 Oct 2013 15:15:48 -0400</lastBuildDate><item><title>Answer by SupportIvyTeam</title><link>https://answers.axonivy.com/questions/14/how-to-create-a-loading-indicator-in-a-html-user-dialog/15</link><description>&lt;p&gt;PrimeFaces offers 2 components for this, &lt;code&gt;p:ajaxStatus&lt;/code&gt; and &lt;code&gt;p:blockUI&lt;/code&gt;. See the following example form in the Html Dialog:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;h:form&amp;gt;
        &amp;lt;p:panel header="p:ajaxStatus and p:blockUI Demo" id="panel"&amp;gt;
                &amp;lt;p:panelGrid columns="1"&amp;gt;
                        &amp;lt;p:ajaxStatus style="width:220px;height:19px;"&amp;gt;
                                &amp;lt;f:facet name="start"&amp;gt;
                                        &amp;lt;h:graphicImage library="ivy-cms" name="Images/loader" /&amp;gt;
                                &amp;lt;/f:facet&amp;gt;

                                &amp;lt;f:facet name="complete"&amp;gt;
                                        &amp;lt;h:outputText value="Done!" /&amp;gt;
                                &amp;lt;/f:facet&amp;gt;
                        &amp;lt;/p:ajaxStatus&amp;gt;
                        &amp;lt;p:commandButton id="btn" value="Trigger ajaxStatus and blockUI"
                                actionListener="#{logic.doSomething}" /&amp;gt;
                        &amp;lt;p:commandButton value="Do not trigger ajaxStatus and blockUI"
                                actionListener="#{logic.doSomething}" global="false"/&amp;gt;

                &amp;lt;/p:panelGrid&amp;gt;
        &amp;lt;/p:panel&amp;gt;
        &amp;lt;p:blockUI block="panel" trigger="btn"&amp;gt;
                LOADING&amp;lt;br /&amp;gt;
                &amp;lt;h:graphicImage library="ivy-cms" name="Images/loader2" /&amp;gt;
        &amp;lt;/p:blockUI&amp;gt;
&amp;lt;/h:form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;
In lines 4 to 12 you see how to configure &lt;code&gt;p:ajaxStatus&lt;/code&gt;. It is triggered every time when a AJAX request is fired, e.g. when a &lt;code&gt;p:commandButton&lt;/code&gt; is pressed. As soon as the request is fired, the content of the &lt;em&gt;start facet&lt;/em&gt; is shown. As soon as the request ends, the content of the &lt;em&gt;complete facet&lt;/em&gt; is displayed.&lt;/p&gt;
&lt;p&gt;If you wish not to trigger &lt;code&gt;p:ajaxStatus&lt;/code&gt; on a &lt;code&gt;p:commandButton&lt;/code&gt;, then you have to set the &lt;code&gt;global&lt;/code&gt; attribute to &lt;code&gt;false&lt;/code&gt; like in line 15.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;p:blockUI&lt;/code&gt; does work differently, Here you have to define which components are blocked (&lt;code&gt;block="panel"&lt;/code&gt;) and which component triggers the block (&lt;code&gt;trigger="btn"&lt;/code&gt;). See lines 20 to 23. &lt;/p&gt;
&lt;p&gt;Any content can be used inside &lt;code&gt;p:ajaxStatus&lt;/code&gt; or &lt;code&gt;p:blockUI&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;&lt;img alt="Progress with p:ajaxStatus and p:blockUI" src="/upfiles/ajaxstatusblockui.png"&gt;&lt;/p&gt;
&lt;p&gt;For more insight, please get the &lt;a href="http://xpert-ivy-hacker-source-code.googlecode.com/svn/trunk/Forms"&gt;example project&lt;/a&gt; or have a look at the demos for &lt;a href="http://www.primefaces.org/showcase/ui/ajaxStatusHome.jsf"&gt;p:ajaxStatus&lt;/a&gt; and &lt;a href="http://www.primefaces.org/showcase/ui/blockUI.jsf"&gt;p:blockUI&lt;/a&gt; on the &lt;a href="http://www.primefaces.org/showcase/ui/home.jsf"&gt;PrimeFaces Showcase&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;
&lt;br&gt;
Note: This question and answer was &lt;a href="http://blog.xpertivyhacker.ch/2012/11/xpertivy-primepush-installieren.html"&gt;originally posted&lt;/a&gt; by Heinrich Spreiter on his &lt;a href="http://blog.xpertivyhacker.ch/"&gt;Xpert.ivy Hacker blog&lt;/a&gt;. Many thanks to Henry for his enthusiastic work. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">SupportIvyTeam</dc:creator><pubDate>Mon, 07 Oct 2013 15:15:48 -0400</pubDate><guid>https://answers.axonivy.com/questions/14/how-to-create-a-loading-indicator-in-a-html-user-dialog/15</guid></item></channel></rss>