Pages

Wednesday, January 16, 2013

How to create a "Processing" panel in RichFaces

Supose you have a page with a form inside to edit some values, and you want to show a "Processing" or "Please Wait" message when you click on a "save" button on that form. In RichFaces you can use the popupPanel compoment to this purpose.

This article assumes you are using RichFaces 4, and JSF/Facelets

I've created this wait.xhtml file containing only the wait panel to favor reusability and maintainability.


<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:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">

<a4j:status name="waitStatus" onstart="#{rich:component('wait')}.show();"
onstop="#{rich:component('wait')}.hide();" />
<rich:popupPanel id="wait" autosized="true"
modal="false" moveable="false" resizeable="false" zindex="2005">
<f:facet name="header">
<h:outputText value="Processing" />
</f:facet>
<h:outputText value="Please wait..." />
</rich:popupPanel>
</ui:composition>


In the page where you have the form, add the reference to that file:

...
<ui:include src="../wait.xhtml" />
</h:form>

Somewhere inside the form you'll have a "Save" button that processes the input:


<a4j:commandButton value="Save"
action="#{bBean.save}"
status="waitStatus"
oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('ap')}.hide(); return false;">
</a4j:commandButton>

The key part for the wait popup panel to appear only when the "Save" commandButton is clicked, is the status="waitStatus" that links the action of the commandButton to the a4j:status that opens the wait panel.

If you don't do it this way, the wait panel will popup upon every ajax call  in the editing form (autocomplete fields, a4j:ajax calls, etc).

Hope this helps, comment if you have problems with this approach.


47 comments:

  1. I read that Post and got it fine and informative. Please share more like that...
    embroidery digitizing

    ReplyDelete
  2. I think about it is most required for making more on this get engaged
    embroidery digitizing

    ReplyDelete
  3. Excellent information on your blog, thank you for taking the time to share with us. Amazing insight you have on this, it's nice to find a website that details so much information about different artists.
    embroidery digitizing

    ReplyDelete
  4. We all chuckle, but then the conversation kind of fizzles out from there. It isn't that we shouldn't believe anything that we find online, it is that we need to be critical of the validity of what we find.
    Vector Digitizing

    ReplyDelete
  5. I am really amazed at the ideal approach to viewing your subject. Where do you collect this information? I want to write great writing like you do.
    야설

    ReplyDelete
  6. Thanks For Sharing Such An Interesting Article, It Is Really Worthy To Read. I Have Subscribed To You And From Now On I'll Check Your Profile Daily For Interesting Stuffs. 야설

    ReplyDelete
  7. I am really amazed at the ideal approach to viewing your subject. Where do you collect this information? I want to write great writing like you do. 국산야동


    ReplyDelete
  8. It’s so good and so awesome. I am just 카지노사이트 amazed. I hope that you continue to do your work like this in the future also.

    ReplyDelete
  9. All your hard work is much appreciated your thoughts. This content data gives truly quality and unique information. I’m definitely going to look into it. Really very beneficial tips are 카지노사이트provided here and, Thank you so much. Keep up the good works.

    ReplyDelete
  10. I do agree with all of the ideas토토 you’ve presented in your post.

    ReplyDelete
  11. Nice one! Thank you for sharing this post. 바카라사이트Your blog posts are more interesting and impressive.

    ReplyDelete
  12. Your web site is actually fantastic. When I saw this, I believed I must function harder on my writing. You're great at creating. I located what I have actually been trying to find for a week. You're excellent at composing. Thanks a lot for letting me discover the info I'm trying to find. 카지노사이트

    ReplyDelete
  13. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. adivinanzas para ninos

    ReplyDelete
  14. I was looking at some of your posts on this website and I conceive this web site is really instructive! Keep putting up.. adivinanzas con las respuestas

    ReplyDelete
  15. ¡Hey! Alguien en mi grupo de Facebook compartió este sitio con nosotros, así que vine a chequearlo. Definitivamente, estoy amando la información. Estoy marcando y estaré tuiteando esto a mis seguidores! Agencia de marketing digital mexico

    ReplyDelete