Primefaces时间线onchanged执行但不调用bean上的方法

Primefaces timeline onchanged executes but does not call method on bean

我正在尝试将 primefaces 添加到现有的 Spring/JSF (myfaces) 项目中。我有实际的时间轴组件在工作(或者至少加载了正确的数据),但事件侦听器似乎无法正常工作。我已经尝试了很多配置,但似乎无法解决这个问题。

<p:timeline id="timeline1" 
        value="#{timelineView.getModel(searchFacade.dataModel)}" 
        editable="true" eventMargin="10" eventMarginAxis="0" 
        start="#{timelineView.start}" 
        end="#{timelineView.end}" 
        showNavigation="true" showButtonNew="true" 
        axisOnTop="true" stackEvents="false"
        oncomplete="styleEvents();">  

    <p:ajax event="changed" listener="#{timelineView.onEdit()}" oncomplete="restyleTimeline()" />  
</p:timeline>

在上面的代码中,changed 事件被触发,并且有一个 AJAX 调用。在浏览器的网络窗格中,我可以看到 AJAX 调用始终是对当前页面的 URL 的调用(就像 /mypage.jsf?conversationCode=a - 我也在使用显然是 Apache Orchestra)

为更改的事件发送的实际表单数据如下所示:

javax.faces.partial.ajax:true
javax.faces.source:timeline1
javax.faces.partial.execute:timeline1
javax.faces.behavior.event:changed
javax.faces.partial.event:changed
timeline1_eventIdx:0
timeline1_startDate:1498881600000
timeline1_endDate:1510894800000
timeline1_group:<div class='timeline-group'><div class='timeline-row timeline-row-group'>Group One/div><div class='timeline-row timeline-row-sub'>Group One subtitle</div><div class='timeline-row timeline-row-details'>Group One details</div></div>
mainForm:j_id_mt_SUBMIT:1
javax.faces.ViewState: Big hash as usual

奇怪的长组名是因为我将输出组名格式化为更详细的行标题。

后面的bean(省略导入和封装):

public class TimelineView<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    TimelineView<T> timelineView;

    public TimelineModel getModel() {
        return timelineView.getModel();
    }
    public TimelineModel getModel(ListDataModel<? extends Row<T>> results) {  
        return timelineView.getModel(results);
    }
    public void setTimelineView(TimelineView<T> timelineView) {
        this.timelineView = timelineView;
    }
    public Date getStart() {  
        return timelineView.getStart();  
    }
    public Date getEnd() {  
        return timelineView.getEnd();  
    }
    public void onEdit(TimelineModificationEvent e) {
        timelineView.onEdit(e);
    }
    public void onSelect(TimelineSelectEvent e) {
        timelineView.onSelect(e);
    }
}

这些方法中的功能和代码并不重要,因为当我设置断点时,我可以看到从未调用过 onEdit 方法,当我在时间线。

因为我有 Spring 处理所有 bean,所以我的配置就是这样,位于 ApplicationContext.xml 文件中:

<bean id="timelineView" class="com.mycompany.projectone.view.timeline.TimelineView" />

我试过在时间轴周围添加一个表格,这没有什么区别,也试过添加 process=":form_id",这导致了错误 "Cannot find component for expression ":form_id""。

作为也适合我需要的替代方案,有谁知道如何将 primefaces 事件发送到 javascript 函数进行处理?例如,如果用户在时间轴中移动项目的起点和终点,我想更新显示的开始和结束日期。

我还想更改或拦截删除行为并修改单击删除 link 时发生的情况。

如有任何帮助,我们将不胜感激。谢谢

编辑


建议的潜在重复既不能解决症状也不能解决实际的解决方案 - 请参阅下面的答案。

好的,答案是 Primfaces timeline 组件必须设置 widgetVar 才能使 p:ajaxpe:javascript 调用正常工作。非常简单的解决方案,但很难找到。