Creating “Please wait” with RichFaces modal panel - No Fluff Just Stuff

Creating “Please wait” with RichFaces modal panel

Posted by: Max Katz on November 11, 2010

Showing user a modal “Please wait” or “Working” dialog is a good way to prevent him or her clicking a button more than once. It can be easily done in RichFaces by combining a4j:status and rich:modalPanel tags.

<h:form>
   <a4j:commandButton value="Do something" 
      action="#{bean.dosomething}"
      status="ajaxStatus"/>
</h:form>
 
<a4j:status id="ajaxStatus"
   onstart="#{rich:component('waitPanel')}
      .show('',{top:'40px', left:'80px',height:'100px', width:'200px'})"
   onstop="#{rich:component('waitPanel')}.hide()" />
 
<rich:modalPanel id="waitPanel" style="text-align:center">
   <h:outputText value="Please wait..."
      style="font-weight:bold;font-size:large" />
</rich:modalPanel>

When the button is clicked, a4j:status is executed. Instead of showing some text or animated image, we use onstart event to open a modal panel. While Ajax request is executing on the server, the modal panel is active and prevents clicking anything on the page. When the request is done, onstop event on status is called and hides the modal panel.

Short and neat, right?

Max Katz

About Max Katz

Max Katz is a Senior Systems Engineer at Exadel. He has been helping customers jump-start their RIA development as well as providing mentoring, consulting, and training. Max is a recognized subject matter expert in the JSF developer community. He has provided JSF/RichFaces training for the past three years, presented at many conferences, and written several published articles on JSF-related topics. Max also leads Exadel's RIA strategy and writes about RIA technologies in his blog, http://mkblog.exadel.com. He is an author of “Practical RichFaces” book (Apress). Max holds a BS in computer science from the University of California, Davis.

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »