Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jsf中的强制组件渲染顺序_Jsf_Jsf 1.2 - Fatal编程技术网

jsf中的强制组件渲染顺序

jsf中的强制组件渲染顺序,jsf,jsf-1.2,Jsf,Jsf 1.2,我有一个(IBM)JSF1.2应用程序,我尝试使用faces管理的bean在页面顶部显示错误, 我的问题是,如果在一个组件getter中创建了一个错误,并且我将其写入faces托管bean(errorbean),那么errorbean没有正确呈现,原因是jsf在另一个组件写入errorbean之前调用errorbean的getter 那么,我如何强制jsf重新呈现整个页面,或者指定首先呈现哪个主管呢 谢谢您不应该在getter方法中执行任何业务工作,而应该在bean的(post)构造函数中执行

我有一个(IBM)JSF1.2应用程序,我尝试使用faces管理的bean在页面顶部显示错误, 我的问题是,如果在一个组件getter中创建了一个错误,并且我将其写入faces托管bean(errorbean),那么errorbean没有正确呈现,原因是jsf在另一个组件写入errorbean之前调用errorbean的getter

那么,我如何强制jsf重新呈现整个页面,或者指定首先呈现哪个主管呢


谢谢

您不应该在getter方法中执行任何业务工作,而应该在bean的(post)构造函数中执行

例如

公共类Bean{
私人名单实体;
@EJB
私人实体服务实体服务;
@施工后
公共void init(){
试一试{
entities=entityService.list();
}捕获(例外e){
字符串消息=字符串格式(“检索实体失败:%s”,例如getMessage());
FacesMessage FacesMessage=新的FacesMessage(FacesMessage.SEVERITY_错误,消息,空);
FacesContext.getCurrentInstance().addMessage(空,facesMessage);
e、 printStackTrace();
}
}
公共列表getEntities(){
返回实体;
}
}
这还提供了一个优势,即业务作业不会被不必要地多次调用

public class Bean {

    private List<Entity> entities;

    @EJB
    private EntityService entityService;

    @PostConstruct
    public void init() {
        try {
            entities = entityService.list();
        } catch (Exception e) {
            String message = String format("Failed to retrieve entities: %s", e.getMessage());
            FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null);
            FacesContext.getCurrentInstance().addMessage(null, facesMessage);
            e.printStackTrace();
        }
    }

    public List<Entity> getEntities() {
        return entities;
    }

}