如何将 JSF 的 jQuery 库包含在 Primefaces UI 中?
我需要在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
outputScript
标记隐式包含该库:请参阅 这个问题了解更多信息。
You can include the library implicitly using an
outputScript
tag:See the answer to this SO question for more info.