在我的JSF应用我需要时调用应用程序阶段来更新UI组件。能不能做到?下面是我迄今所产生的代码:

    public void resetDataScroller(ActionEvent actionEvent) {

    final FacesContext ctx = FacesContext.getCurrentInstance();

    ctx.getViewRoot().invokeOnComponent(ctx, "paginator_and_table:scroll_1", new ContextCallback() {
        public void invokeContextCallback(FacesContext facesContext, UIComponent uiComponent) {

            HtmlDatascroller htmlDatascroller = (HtmlDatascroller) uiComponent;

            htmlDatascroller.setPage(1);
            htmlDatascroller.setValue(1);


        }
    });

}

这个动作侦听器,查找dataScroller组件,并设置页面,价值为1。很遗憾,似乎并没有在所有的工作,因为渲染dataScroller比1不同的页面

我这么想吗?

有帮助吗?

解决方案

我想你resetDataScroller被叫由命令按钮/链路的actionListener属性在网页上的方法?

我真的不明白你正在尝试做的...你只需要编写代码? :

public void resetDataScroller(ActionEvent evt) {
    final FacesContext ctx = FacesContext.getCurrentInstance();
    HtmlDatascroller htmlDatascroller = (HtmlDatascroller) ctx.getViewRoot().findComponent("paginator_and_table:scroll_1");
    htmlDatascroller.setPage(1);
    htmlDatascroller.setValue(1);
}

如果您在这个阶段改变HtmlDatascroller的这些特性,他们将通过JSF在最后阶段(Render Response阶段)用于生成HTML代码...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top