views:

393

answers:

1

Hello,

in my JSF application i need to update ui component during invoke application phase. Can it be done? Here's the code i've produced so far:

    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);


        }
    });

}

This action listener looks up dataScroller component and sets page and value to 1. Unfortunatelly it doesn't seem to work at all, because rendered dataScroller has page different than 1.

Am i missing something?

+1  A: 

I imagine that your resetDataScroller a method called by an actionListener attribute of a command button/link on your page?

I don't really understand what you are trying to do... Do you just need to write this code? :

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);
}

If you change these properties of the HtmlDatascroller during this phase, they will be used by JSF during the last phase (the Render Response phase) to generate your HTML code...

romaintaz