How to target entire JSF page to be blocked by p:blockUI / pe:blockUI?

12,731

Give an id to your body and then reference it on the block argument of the <p:blockUI> component.

Example:

<h:body id="entirePage"/>

and

<p:blockUI id="blockUI" widgetVar="blockBodyUIWidget" block=":entirePage"/>
Share:
12,731

Related videos on Youtube

Tiny
Author by

Tiny

Just an orphan kid and have no more to say. Three things in general, cannot be avoided (at least I can never) Mother Mother-tongue Mother-land. They are always unique. I'm a family-less boy. My family was hunted leaving me all alone when my house targeted and deliberately set on a fire by a mob during a nonsense communal riot but I was survived by a rescue team with the help of firemen. As a survival, I didn't know whether it was my fortune or misfortune but when I recovered, the rescue team came to my home, one day. One of the members gave me a piece of paper in my hand in which the following text was written. lifeisnowhere. He asked me to read it carefully and I could hardly interpret the text as Life is now here, instead of Life is nowhere. All of them gave me a cute smile and went away and I decided to live peacefully and hopefully on their saying from then onwards and very soon. Because of this tragedy, I'm alone couldn't join a school but a curiosity to learn something made me a self-learner. I'm indeed a self-learner, so I'm likely not able to answer any questions on this site right now. In the field of computer science, my self-study mainly includes, QBASIC, C, C++, C#, VB, Java, JavaScript, PHP and a little about ASP.NET. Oracle, MySQL and MSSQL-Server with DBMS. and other theoretical subjects. I'm currently dealing with - Android and Java EE including Servlet, JSP-JSTL/EL (with Spring and Struts with ORM models JPA/Hibernate) and JSF.

Updated on September 15, 2022

Comments

  • Tiny
    Tiny over 1 year

    The example demonstrates blocking of <h:form> by <pe:blockUI>.

    <h:form id="form" prependId="true">
        <pe:blockUI target="form" widgetVar="blockBodyUIWidget">
            <h:panelGrid columns="2">
                <h:graphicImage library="default" name="images/ajax-loader1.gif" class="block-ui-image"/>
                <h:outputText value="#{messages['blockui.panel.message']}" class="block-ui-text"/>
            </h:panelGrid>
        </pe:blockUI>
    
    <p:commandButton id="btnSubmit" 
                     onstart="PF('blockBodyUIWidget').block()" 
                     oncomplete="PF('blockBodyUIWidget').unblock();}" 
                     update=":form:dataGrid" actionListener="#{bean.listener}" 
                     icon="ui-icon-check" 
                     value="Save">
    </h:form>
    

    This blocks <h:form> but there is a template with a header and a left side bar which are not blocked by doing so.

    I have tried to block <h:body id="body"> <pe:blockUI target="body"... on the template page but that didn't work ending with an exception indicating, "Cannot find component with the id body in the view."

    So, how to target the entire page?

    Although I'm using <pe:blockUI> of PrimeFaces extension, the same thing can be demonstrated by <p:blockUI> of PrimeFaces

  • Tiny
    Tiny over 10 years
    Oh yes! I forgot to prefix : before the id in the target attribute of <pe:blockUI>, indeed, sorry. It should have been target=":body". Thanks.
  • Marin
    Marin over 9 years
    i have one problem like yours, basically exists one page with one button and this button have one link to page 2. How to lock the page 1 during the load time for page 2?