简体   繁体   中英

@ManagedProperty Managed bean between scopos alias

I'm not able to inject a ManagedBean with scope view in another well with same scope, is it possible?

Example:

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;        

Yes it is and don't forget to add getter and setter for carBean like this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM