@ManagedProperty scopos别名之间的托管bean

时间:2017-04-04 16:37:32

标签: java jsf

我无法在具有相同范围的另一个井中注入具有范围视图的ManagedBean,是否可能?

示例:

CarBean

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ViewScoped
@ManagedBean(name="carBean")
public class CarBean{}

EngineBean

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ViewScoped
@ManagedBean
public class EngineBean {
@ManagedProperty(value="#{carBean}")
private CarBean carBean;        

1 个答案:

答案 0 :(得分:0)

是的,不要忘记为carBean添加getter和setter

public CarBean getCarBean(){
    return carBean;
}
public void setCarBean(CarBean carBean){
    this.carBean = carBean;
}