Search code examples
jsf-2primefacesfacelets

How to use <p:blockUI> on whole view?


I want to use <p:blockUI> to block the whole view. But as it's attribute block does only accept ids as keywords and not e.g. @all, the only way I currently see is to have a naming container (e.g. <f:subview>) to wrap the whole content of the view.

Unfortunately that's semantically dirty and I would need to rename all absolute ids because a new unneccessary (except for <p:blockUI>) id-"prefix" has been created.

Is there a cleaner way to do this?


Solution

  • Assuming I understand correctly, you could simply add an id to h:body and reference that id in the block attribute of <p:blockUI>. Also, you wouldn't need to change the ids of your components. Quick example

    <h:body id="wholeView">  
        <h:form>
            <h:inputText/><br/>
            <h:inputText/><br/>
            <p:commandButton id="pnlBtn" value="Block Panel" type="button" onclick="bui.show()"/>  
            <p:blockUI block=":wholeView" widgetVar="bui"/>  
        </h:form>     
    </h:body>
    

    Again, this is just a silly example which simply blocks the view for demonstration purposes. However, from what I understand from the answer below, you would need to be using Mojarra 2.1.8 or higher to use the id from h:body.

    How to spefic the body id attribute in JSF 2?