如何将 JSF 的 jQuery 库包含在 Primefaces UI 中?

发布于 2024-12-11 10:40:26 字数 690 浏览 4 评论 0原文

我需要在 JSF 模板页面中使用 jQuery 和 jQuery UI,但是,Primefaces 有自己的 jQuery,可以按需加载。即,如果页面中没有 标签,Primefaces 将不会加载 jQuery。

我可以有一个虚拟表单来包含所有必需的库,如下所示:

    <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>

虽然它有效,但有更好的解决方案吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖凝香 2024-12-18 10:40:27

您可以使用 outputScript 标记隐式包含该库:

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

请参阅 这个问题了解更多信息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文