Getting backing bean value with Javascript

后端 未结 2 892
予麋鹿
予麋鹿 2020-11-28 12:06

JSF 2.0, Mojarra 2.0.1, PrimeFaces 3.4.1

There are similar questions but I need sth. else; javascript function has to wait for the backing bean method, whic

2条回答
  •  一个人的身影
    2020-11-28 12:47

    EL in your JavaScript is calculated when page is rendered and you can update its container (if it is in some JSF component), but I would suggest another approach.

    As you are making AJAX request, you can add callback parameter in getStatuses() method. You can use Primefaces's RequestContext utility method addCallBackParam() for this:

    public void getStatuses() {
        this.panelList = fillList();
        this.size = panelList.size();
        RequestContext.getCurrentInstance().addCallBackParam("size", this.size);
    }
    

    and you can use this parameter in xhtml:

    
    
    
    

提交回复
热议问题