问题描述
我从此页面中添加了PrimeFaces计划得到了如下结果:
I have added PrimeFaces schedule from this page and got the results like the following:
我以下事件正常运行,但是单击prev
或next
时如何获取和处理事件?
I got the following events working fine but how do I get and handle events when prev
or next
is clicked?
我还突出显示了图像中的其他内容:
I have also highlighted some more in the image:
<p:ajax event="dateSelect" listener="#{scheduleJava8View.onDateSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
<p:ajax event="eventSelect" listener="#{scheduleJava8View.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
<p:ajax event="eventMove" listener="#{scheduleJava8View.onEventMove}" update="messages" />
<p:ajax event="eventResize" listener="#{scheduleJava8View.onEventResize}" update="messages" />
推荐答案
要捕获日期/查看服务器中/您的bean中的更改,我发现最简单的方法就是进行延迟加载(展示,文档).基本上,这将使您在Bean中有一个方法,在该方法中,如果视图发生更改,则传递开始日期和结束日期:
To capture dates / view changes on the server / in your bean, I found it easiest to just go for lazy loading (showcase, documentation). This will basically allow you to have a method in the bean where the start and end date are passed in case the view changes:
lazyModel = new LazyScheduleModel() {
@Override
public void loadEvents(LocalDateTime start, LocalDateTime end) {
//
}
};
..作为奖励,您的活动将被延迟加载!
.. and as a bonus, your events will be lazily loaded!
请注意,日期类型(java.time.LocalDateTime
或java.util.Date
)将取决于PrimeFaces版本.请参阅迁移指南.
Note that the type of dates (java.time.LocalDateTime
or java.util.Date
) will depend on the PrimeFaces version. See the migration guide.
要修改UI,您需要知道PrimeFaces对p:schedule
组件使用了 FullCalendar .您可以使用 extender
属性并根据需要配置FullCalendar.请参阅工具栏文档.请注意,FullCalendar的版本将取决于PrimeFaces版本.再次,请参阅迁移指南.
To modify the UI, you need to know that PrimeFaces is using FullCalendar for the p:schedule
component. You can use the extender
attribute and configure the FullCalendar to your needs. See the toolbar documentation. Note that the version of FullCalendar will depend on the PrimeFaces version. Again, see the migration guide.
要设置时间格式,请使用timeFormat
属性.它使用 Moment.js .您可以使用hh:mmA
.在 https://www.primefaces.org/showcase/ui上尝试/data/schedule/configureable.xhtml
To set the time format, use the timeFormat
attribute. It uses Moment.js. You could use hh:mmA
. Try it on https://www.primefaces.org/showcase/ui/data/schedule/configureable.xhtml
这篇关于单击prev,next时如何获取事件:带有Primefaces的时间表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!