How to include jQuery library for JSF with Primefaces UI?

15,780

You can include the library implicitly using an outputScript tag:

<h:outputScript library="primefaces" name="jquery/jquery.js"/>

See the answer to this SO question for more info.

Share:
15,780
Lenik
Author by

Lenik

+--[ RSA 1024]----+ | | | | | . . o | | . o o o o | | S . o + .| | . . + + o | | . . . . . o + | | = o . o . | | =.. ooE| +-----------------+ 1024 aa:0c:4f:fb:15:5c:7e:4c:e7:f1:ca:61:8a:fd:0f:fe X.J. Lenik (RSA)

Updated on June 17, 2022

Comments

  • Lenik
    Lenik almost 2 years

    I need to use jQuery and jQuery UI in JSF template pages, however, Primefaces have its own jQuery which is loaded on demand. I.e., Primefaces won't load jQuery if there is no <p:xxx> tag in the page.

    I can have a dummy form to include all the required libraries like following:

        <h:form id="dummy" style="display: none;">
            A Dummy Form.
            <p:dataTable />
            <p:column />
            <p:commandLink />
            <p:commandButton />
            <p:dialog />
            <p:fileUpload />
            <p:tabView rendered="false">
                <p:tab title="" />
            </p:tabView>
            <p:message for="dummy" />
            <f:ajax event="click" />
        </h:form>
    

    though it works, but is there any better solution?