日历未弹出 PrimeFaces
我正在尝试将日历效果(使用 Primeface)添加到我的 JSF 网页。我正在使用 Netbeans 6.9.1 和 glassfish 3.1。
我按照 此博客 中所述将 Primeface 安装到我的应用程序中,
并从Primefaces 网站。我复制了整个表单并将其粘贴到我的 xhtml 文件中。我相应地改变了 bean 类。
我的网页上没有弹出日历。为什么会出现这种情况。我在 Chrome 和 Firefox 上测试了这个,仍然没有成功。有人可以帮助我吗
I am trying to add the Calendar effect (using Primeface) to my JSF web page. i am using Netbeans 6.9.1 and glassfish 3.1.
I installed Primeface to my application as described in this blog
And copied some code from Primefaces website. I copied the entire form and pasted it on my xhtml file. and i changed the bean class accordingly.
I am not getting the Calendar pop up in my web page. Why is this happening. I tested this on Chrome and Firefox still no luck. Can someone help me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,确保您已在 XML 命名空间中声明了 PrimeFaces 标记库。对于当前的 PrimeFaces 2.x 版本(即
Second),PrimeFaces 附带了大量 CSS/JS 资源,这些资源应该由
自动包含。日历组件(以及许多其他组件)正是由这些资源设计和激活的。因此,为了让它们自动包含,您需要确保您的母版中有
而不是模板。为了保持一致,请将
替换为
。根据评论更新,存在 JavaScript 冲突。
在其最简单的形式下工作得很好。它停止工作,因为您的模板中有一个 jQuery 菜单栏,而该菜单栏又需要。由于 PrimeFaces 已经捆绑了 jQuery,因此它很可能与手动包含的 jQuery 脚本发生冲突。您需要摆脱手动 jQuery 脚本包含。
First, ensure that you've declared the PrimeFaces tag library in your XML namespace. For the current PrimeFaces 2.x version, that is
Second, PrimeFaces comes along with a lot of CSS/JS resources which are supposed to be auto-included by a
<h:head>
. The calendar component (and many others) are styled and activated by exactly those resources. So, in order to get them to auto-included, you need to ensure that you've a<h:head>
instead of<head>
in your master template. And to be consistent, replace<body>
by<h:body>
as well.Update based on the comments, there was a JavaScript conflict. The
<p:calendar>
works fine at its simplest form. It ceased to work because you've a jQuery menubar in your template which in turn would require a<script src="jquery.js">
. Since PrimeFaces already ships with jQuery bundled, it has most likely conflicted with the manual jQuery script include. You need to get rid of the manual jQuery script include.当您使用 jquery datepicker 小部件并且我假设还使用日历小部件时,您可以设置区域参数以使用特定国家/地区的日期格式。
例如:
$.datepicker.setDefaults( $.datepicker.regional[ "en-GB" ] );
如果您这样做,您必须包含适当的定义,例如
<脚本类型=“text/javascript”src=“js/datepicker-en-GB.js”>
When you use the jquery datepicker widget and I assume also the calendar widgit you can set the regional parameter to use date formats of a particular country.
For example:
$.datepicker.setDefaults( $.datepicker.regional[ "en-GB" ] );
If you do this you must include the appropriate definitions, e.g.
<script type="text/javascript" src="js/datepicker-en-GB.js"></script>