Lenik
Lenik

Reputation: 14458

How to include jQuery library for JSF with Primefaces UI?

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?

Upvotes: 2

Views: 16090

Answers (1)

Jonathan Spooner
Jonathan Spooner

Reputation: 7752

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.

Upvotes: 17

Related Questions