0

我已经将一个视图范围 bean 注入到另一个视图范围 bean 中,并且我可以访问第一个 bean 的一些属性,但其他属性在 @PostContruct 中显示为 null。我怎样才能看到它们的真正价值?

提前致谢

更新:我只能看到在第一个 bean 的 @PostContruct 中更新的属性值,而不是其他

Bean 1(SelectOfferMpans)

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sofyc.backingbean.offer;

import es.iberdrola.configuration.LogginManager;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.SelectItem;
import org.apache.log4j.Logger;
import sofyc.bean.BeanInstanceLocator;
import sofyc.bean.IOffersBean;
import sofyc.corejsf.SofycNavigation;
import sofyc.corejsf.SofycParamNames;
import sofyc.utils.JSFHelper;
import sofyc.valueobject.CustomerFindVO;
import sofyc.valueobject.MpanVO;
import sofyc.valueobject.OfferSitesVO;

@ManagedBean
@ViewScoped
public class SelectOfferMpans implements Serializable{

/**
 * Logger.
 */
private static Logger log = LogginManager.getLogger(SelectOfferMpans.class.getName());

static {          
    adq_ren_types = new String[2];
}

private final String ID_OFFER_SELECT_MPANS_FORM = "selectMpans"; 

private String menuOrigin;

/**
 * Parametro de busqueda del formulario.
 */
private String registrationNumber;

private List<CustomerFindVO> customerfoundList;

private CustomerFindVO customerfound;

private String companyRegNo;

private String customerId;

private CustomerFindVO selectedCustomer;

private List<OfferSitesVO> offerSites;

private List<OfferSitesVO> filteredSites;

private OfferSitesVO selectedSite; 

private OfferSitesVO[] selectedSites;

private List<MpanVO> siteMpans;

private SelectItem[] hh_nhh_List;  

private SelectItem[] adq_ren_List;

private final static String[] adq_ren_types;

private Map<String,String> hh_nhh_types;

public Map<String, String> getHh_nhh_types() {
    return hh_nhh_types;
}

public void setHh_nhh_types(Map<String, String> hh_nhh_types) {
    this.hh_nhh_types = hh_nhh_types;
}

public SelectItem[] getHh_nhh_List() {
    return hh_nhh_List;
}

public void setHh_nhh_List(SelectItem[] hh_nhh_List) {
    this.hh_nhh_List = hh_nhh_List;
}

public SelectItem[] getAdq_ren_List() {
    return adq_ren_List;
}

public void setAdq_ren_List(SelectItem[] adq_ren_List) {
    this.adq_ren_List = adq_ren_List;
}    

public List<OfferSitesVO> getOfferSites() {
    return offerSites;        
}

public void setOfferSites(List<OfferSitesVO> offerSites) {
    this.offerSites = offerSites;
}

public List<OfferSitesVO> getFilteredSites() {
    return filteredSites;
}

public void setFilteredSites(List<OfferSitesVO> filteredSites) {
    this.filteredSites = filteredSites;
}

public OfferSitesVO getSelectedSite() {
    return selectedSite;
}

public void setSelectedSite(OfferSitesVO selectedSite) {
    this.selectedSite = selectedSite;
}

public OfferSitesVO[] getSelectedSites() {
    return selectedSites;
}

public void setSelectedSites(OfferSitesVO[] selectedSites) {
    this.selectedSites = selectedSites;
}

public List<MpanVO> getSiteMpans() {
    return siteMpans;
}

public void setSiteMpans(List<MpanVO> siteMpans) {
    this.siteMpans = siteMpans;
}

public CustomerFindVO getSelectedCustomer() {
    return selectedCustomer;
}

public void setSelectedCustomer(CustomerFindVO selectedCustomer) {
    this.selectedCustomer = selectedCustomer;
}

public String getCustomerId() {
    return customerId;
}

public void setCustomerId(String customerId) {
    this.customerId = customerId;
}

public String getCompanyRegNo() {
    return companyRegNo;
}

public void setCompanyRegNo(String companyRegNo) {
    this.companyRegNo = companyRegNo;
}

public List<CustomerFindVO> getCustomerfoundList() {
    return customerfoundList;
}

public void setCustomerfoundList(List<CustomerFindVO> customerfoundList) {
    this.customerfoundList = customerfoundList;
}

public String getRegistrationNumber() {
    return registrationNumber;
}

public void setRegistrationNumber(String registrationNumber) {
    this.registrationNumber = registrationNumber;
}

public CustomerFindVO getCustomerfound() {
    return customerfound;
}

public void setCustomerfound(CustomerFindVO customerfound) {
    this.customerfound = customerfound;
}

public String getMenuOrigin() {
    return menuOrigin;
}

public void setMenuOrigin(String menuOrigin) {
    this.menuOrigin = menuOrigin;
}

/**
 * Creates a new instance of SelectOfferMpans
 */
public SelectOfferMpans() {
}

@PostConstruct    
public void init() {
    try{
        if(log.isDebugEnabled()) {
            log.debug("INIT");
        } 

        if (getMenuOrigin() == null) {
            setMenuOrigin(JSFHelper.getParameterFromView("OPTION"));     
            if (getMenuOrigin() == null) {
                setMenuOrigin((String) JSFHelper.getParameterFromRequest("OPTION"));
            }
            if (log.isDebugEnabled()) {
                log.debug("CREATE OFFER --> guardado en VIEW VAR menuOrigin el "
                        + "valor recuperado en la Request del parametro OPTION:: " 
                        + getMenuOrigin());
            }
        }

        adq_ren_types[0] = "Adquisitions";
        adq_ren_types[1] = "Renews";

        this.setHh_nhh_types(cargaHHNHH());

        //hh_nhh_List = createFilterOptions(hh_nhh_types);
        hh_nhh_List = createFilterOptions1(hh_nhh_types,true);
        adq_ren_List = createFilterOptions(adq_ren_types);   

    }catch(Exception e)
    {
        log.error("SearchCustomer:Init", e);
        JSFHelper.addErrorMessage("messagesError", e.getMessage());            
    }
}

public void findCustomer() throws Exception {    
    CustomerFindVO customer=null;
    try{        
        if (log.isDebugEnabled()) {
            log.debug("Searching Customer....");
        }

        IOffersBean offersBean = BeanInstanceLocator.getOffersBean();
        customerfound = offersBean.searchCustomer(companyRegNo);
        if (customerfound!=null){
            this.setOfferSites(offersBean.getCustomerSites(customerfound.getCustomerId()));                
        }
        else{
            this.setOfferSites(null);
            JSFHelper.addErrorMessage(ID_OFFER_SELECT_MPANS_FORM, "Error searching customer");
        }

        if (log.isDebugEnabled()) {
            log.debug("Customer Data Found");
        }

    } catch (Throwable t) {
        log.error("findCustomer:", t);
        JSFHelper.addErrorMessage(ID_OFFER_SELECT_MPANS_FORM, "Error searching customer");                        
    }
}

public String goToOffers(){
    try{

        JSFHelper.addParamToRequest(SofycParamNames.CUSTOMER_ID, customerfound.getCustomerId());
        JSFHelper.addParamToRequest(SofycParamNames.OPTION, this.getMenuOrigin());
        return SofycNavigation.VIEW_CREATE_OFFERS_PAGE;

    } catch (Throwable t) {
        log.error("goToOffers:", t);
        JSFHelper.addErrorMessage(ID_OFFER_SELECT_MPANS_FORM, "Error navigating to offers page");            
        return null;
    }
}        

private SelectItem[] createFilterOptions(String[] data)  {  
    SelectItem[] options = new SelectItem[data.length + 1];  

    options[0] = new SelectItem("", "Select");         
    for(int i = 0; i < data.length; i++) {  
        options[i + 1] = new SelectItem(data[i], data[i]);  
    }  

    return options;  
}

private SelectItem[] createFilterOptions1(Map<String,String> data, boolean select)  {  
    //SelectItem[] options = new SelectItem[data.size() + 1];  
    SelectItem[] options;
    int i = 0;

    if (select==true) {
        options = new SelectItem[data.size() + 1];
        options[i] = new SelectItem("", "Select");  
        i++;
    }
    else{
        options = new SelectItem[data.size()];
    }
    for (Map.Entry e: data.entrySet()) { 
        options[i] = new SelectItem(e.getKey().toString(), e.getValue().toString());  
        //options[i + 1] = new SelectItem(e.getValue().toString(),e.getKey().toString());  
        i++;
    } 

    return options;  
}

private Map<String,String> cargaHHNHH() {
     Map<String,String> hh_nhh_types= new HashMap<String,String>();

    hh_nhh_types.put("HH","HH");
    hh_nhh_types.put("NHH","NHH");
    return hh_nhh_types;
}

}

第一个 bean 的 Bean 2(CreateOffer) 属性 selectedSites 始终显示为 null,并且在 findCustomer 方法中加载。

package sofyc.backingbean.offer;

import es.iberdrola.configuration.LogginManager;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.apache.log4j.Logger;
import org.primefaces.event.SelectEvent;
import org.primefaces.event.ToggleEvent;
import org.primefaces.event.UnselectEvent;
import sofyc.bean.BeanInstanceLocator;
import sofyc.bean.IOffersBean;
import sofyc.utils.JSFHelper;
import sofyc.valueobject.CustomerVO;
import sofyc.valueobject.MddMeasurementClassVO;
import sofyc.valueobject.MpanVO;
import sofyc.valueobject.OfferSitesVO;
import sofyc.valueobject.ProfileClassVO;
import sofyc.valueobject.SiteVO;
import sofyc.valueobject.TradebookVO;


@ManagedBean
@ViewScoped
public class CreateOffer implements Serializable {

private static Logger log = LogginManager.getLogger(CreateOffer.class.getName());    
/**
 * Creates a new instance of CreateOffer
 */
static {          
    adq_ren_types = new String[2];
}  

@ManagedProperty(value="#{selectOfferMpans.selectedSites}")
//@ManagedProperty(value="#{selectOfferMpans}")
//private SelectOfferMpans selectOfferMpans;
private OfferSitesVO[] selectedSites;

/*public void setSelectOfferMpans(SelectOfferMpans selectOfferMpans) {
    this.selectOfferMpans = selectOfferMpans;
}*/

public void setSelectedSites(OfferSitesVO[] selectedSites) {
    this.selectedSites = selectedSites;
}

/**
 * Valores posibles de donde viene la pagina.
 */    
private final String CREATE_OFFERS_OPTION = "CREATE";
private final String OFFERS_OPTION = "OFFERS";

private String menuOrigin;

/**
 * Corresponde a la columna CUSTOMER_ID.
 */
private Integer customerId;

private Map<String,String> managers;
private Date offerFromDate;
private Date offerToDate;
private Date expiryDate;

private Integer tradeBookId;

private String creditScore;

private String consultantMargin;
private String spMargin;

private Integer productId;
private Integer profileClassId;        
private String measurementClassId;    
private Integer curveId;    

/**
 * Customer selected.
 */
private CustomerVO customer;    
private List<OfferSitesVO> offerSites;
private List<OfferSitesVO> filteredSites;
private OfferSitesVO selectedSite;      
private OfferSitesVO[] selectedSites1;

public OfferSitesVO[] getSelectedSites1() {
    return selectedSites1;
}

public void setSelectedSites1(OfferSitesVO[] selectedSites1) {
    this.selectedSites1 = selectedSites1;
}
private List<MpanVO> siteMpans;    
//private final static String[] hh_nhh_types;
private Map<String,String> hh_nhh_types;

private final static String[] adq_ren_types;
//private final static String[] cotOfferTypes;
private Map<String,String> cotOfferTypes;
private Map<String,String> offerType;

private Map<String,String> loadCurve;
//private final static String[] offerType;
//private final static String[] loadCurve;

private SelectItem[] hh_nhh_List;  
private SelectItem[] adq_ren_List;
private SelectItem[] cotOfferList;
private String cotOfferSelection;
private String comcOfferSelection;
private String copcOfferSelection;
private String offerTypeSelection;
private String loadCurveSelection;

//La oferta es de tipo HH o NHH
private String offerHH_NHH;

private SelectItem[] offerTypeList;
private SelectItem[] loadCurveList;

/**
 * Site selected.
 */
private SiteVO site;    
private MpanVO mpan;        
private List<SiteVO> sites;    
private List<MpanVO> mpans;

private List<TradebookVO> tradeBookList;
private Map<String,Integer> ProductList;    
private List<ProfileClassVO> profileClassList;        
private List<MddMeasurementClassVO> measurementClassList;
private Map<String,Integer> CurveList;

@PostConstruct    
public void init() {

    if(log.isDebugEnabled()) {
        log.debug("********************** CreateOffer::init **********************");
    }

    if (getMenuOrigin() == null) {
            setMenuOrigin(JSFHelper.getParameterFromView("OPTION"));     
            if (getMenuOrigin() == null) {
                setMenuOrigin((String) JSFHelper.getParameterFromRequest("OPTION"));
            }
            if (log.isDebugEnabled()) {
                log.debug("CREATE OFFER --> guardado en VIEW VAR menuOrigin el "
                        + "valor recuperado en la Request del parametro OPTION:: " 
                        + getMenuOrigin());
            }
    }

    adq_ren_types[0] = "Adquisitions";
    adq_ren_types[1] = "Renews";

    //Valor por defecto de COT        
    cotOfferSelection="0";
    //Valor por defecto de COMC
    comcOfferSelection="0";
    //Valor por defecto de COPC
    copcOfferSelection="0";
    //Valor por defecto de OfferType
    offerTypeSelection="0";
    //Valor por defecto de loadCurve
    loadCurveSelection="0";

    offerHH_NHH="NHH";

    this.setHh_nhh_types(cargaHHNHH());

    //hh_nhh_List = createFilterOptions(hh_nhh_types);
    hh_nhh_List = createFilterOptions1(hh_nhh_types,true);
    adq_ren_List = createFilterOptions(adq_ren_types);        
    //cotOfferList = createFilterOptions(cotOfferTypes);
    this.setCotOfferTypes(cargaCOT());
    cotOfferList = createFilterOptions1(cotOfferTypes,false);
    this.setOfferType(cargaofferType());
    offerTypeList = createFilterOptions1(offerType,false);
    this.setLoadCurve(cargaloadCurve());
    loadCurveList = createFilterOptions1(loadCurve,false);

    populateRequestParamsInViewVars();

    initCustomerInfo();

    CurveList = new LinkedHashMap<String,Integer>();
    ProductList = new LinkedHashMap<String,Integer>();

    //hh_nhh_List = new LinkedHashMap<String,Integer>();
    profileClassId=2;
    measurementClassId="A";
    curveId=1;
    tradeBookId=3;
    profileClassList = new ArrayList<ProfileClassVO>();        
    measurementClassList = new ArrayList<MddMeasurementClassVO>();
    tradeBookList = new ArrayList<TradebookVO>();

    loadProfileClass();
    loadMeasurementClass();
    loadTradeBook();        

    }
public void onRowSelect(SelectEvent event) {  
    //FacesMessage msg = new FacesMessage("Car Selected", ((Car) event.getObject()).getModel());    
    //FacesContext.getCurrentInstance().addMessage(null, msg);  
    //event.getComponent().
}  

public void onRowUnselect(UnselectEvent event) {  
    //FacesMessage msg = new FacesMessage("Car Unselected", ((Car) event.getObject()).getModel());    
    //FacesContext.getCurrentInstance().addMessage(null, msg);  
}  

public String getOfferTypeSelection() {
    return offerTypeSelection;
}

public void setOfferTypeSelection(String offerTypeSelection) {
    this.offerTypeSelection = offerTypeSelection;
}

public String getLoadCurveSelection() {
    return loadCurveSelection;
}

public void setLoadCurveSelection(String loadCurveSelection) {
    this.loadCurveSelection = loadCurveSelection;
}

public SelectItem[] getOfferTypeList() {
    return offerTypeList;
}

public void setOfferTypeList(SelectItem[] offerTypeList) {
    this.offerTypeList = offerTypeList;
}

public SelectItem[] getLoadCurveList() {
    return loadCurveList;
}

public void setLoadCurveList(SelectItem[] loadCurveList) {
    this.loadCurveList = loadCurveList;
}

public List<ProfileClassVO> getProfileClassList() {
    return profileClassList;
}

public void setProfileClassList(List<ProfileClassVO> ProfileClassList) {
    this.profileClassList = ProfileClassList;
}  

public MpanVO getMpan() {
    return mpan;
}

public void setMpan(MpanVO mpan) {
    this.mpan = mpan;
}

public List<MpanVO> getMpans() {
    return mpans;
}

public void setMpans(List<MpanVO> mpans) {
    this.mpans = mpans;
}

public List<SiteVO> getSites() {
    return sites;
}

public void setSites(List<SiteVO> sites) {
    this.sites = sites;
}

public CustomerVO getCustomer() {
    return customer;
}

public void setCustomer(CustomerVO customer) {
    this.customer = customer;
}

public SiteVO getSite() {
    return site;
}

public void setSite(SiteVO site) {
    this.site = site;
}

public String getCreditScore() {
    return creditScore;
}

public void setCreditScore(String creditScore) {
    this.creditScore = creditScore;
}

public String getConsultantMargin() {
    return consultantMargin;
}

public void setConsultantMargin(String consultantMargin) {
    this.consultantMargin = consultantMargin;
}

public String getSpMargin() {
    return spMargin;
}

public void setSpMargin(String spMargin) {
    this.spMargin = spMargin;
}

public List<OfferSitesVO> getOfferSites() {
    return offerSites;
}

public void setOfferSites(List<OfferSitesVO> offerSites) {
    this.offerSites = offerSites;
}

public List<OfferSitesVO> getFilteredSites() {
    return filteredSites;
}

public void setFilteredSites(List<OfferSitesVO> filteredSites) {
    this.filteredSites = filteredSites;
}

public SelectItem[] getAdq_ren_List() {
    return adq_ren_List;
}

public void setAdq_ren_List(SelectItem[] adq_ren_List) {
    this.adq_ren_List = adq_ren_List;
}

public SelectItem[] getHh_nhh_List() {
    return hh_nhh_List;
}

public void setHh_nhh_List(SelectItem[] hh_nhh_List) {
    this.hh_nhh_List = hh_nhh_List;
}

public Map<String, String> getHh_nhh_types() {
    return hh_nhh_types;
}

public void setHh_nhh_types(Map<String, String> hh_nhh_types) {
    this.hh_nhh_types = hh_nhh_types;
}

public Map<String, String> getOfferType() {
    return offerType;
}

public void setOfferType(Map<String, String> offerType) {
    this.offerType = offerType;
}

public Map<String, String> getLoadCurve() {
    return loadCurve;
}

public void setLoadCurve(Map<String, String> loadCurve) {
    this.loadCurve = loadCurve;
}

public String getOfferHH_NHH() {
    return offerHH_NHH;
}

public void setOfferHH_NHH(String OfferHH_NHH) {
    this.offerHH_NHH = OfferHH_NHH;
}

public String getMenuOrigin() {
    return menuOrigin;
}

public void setMenuOrigin(String menuOrigin) {
    this.menuOrigin = menuOrigin;
}
/**
 * Metodo que inicializa los valores del cliente.
 */
private void initCustomerInfo() {        

    this.setSites(new ArrayList<SiteVO>());    
    this.setMpans(new ArrayList<MpanVO>());    
    List<OfferSitesVO> offerSitesAux = new ArrayList<OfferSitesVO>();

    FacesMessage msg = null;
    try{
        log.debug("initCustomerInfo: Start");

        IOffersBean offerBean = BeanInstanceLocator.getOffersBean();                
        this.setCustomer(offerBean.getCustomer(customerId));  
        this.setManagers(offerBean.getManagerList());


        if (CREATE_OFFERS_OPTION.equals(menuOrigin)){ 
            if (selectedSites!=null){
                for(int i = 0; i < selectedSites.length; i++){
                    offerSitesAux.add(selectedSites[i]);
                }
            }

            this.setOfferSites(offerSitesAux);
        }
        else{
            this.setOfferSites(offerBean.getCustomerSites(customerId));
        }                        


        this.setHh_nhh_List(offerBean.getHHNHHList());
        this.setAdq_ren_List(offerBean.getAdquisitionRenewList());


    }catch(Exception e){
        msg = new FacesMessage("ERROR "+e.getMessage());   
        FacesContext.getCurrentInstance().addMessage(null, msg);   
        log.error("ERROR 2:: "+e.getMessage());
    }
}        

public Integer getProductId() {
    return productId;
}

public void setProductId(Integer ProductId) {
    this.productId = ProductId;
}    

public List<TradebookVO> getTradeBookList() {
    return tradeBookList;
}

public void setTradebookList(List<TradebookVO> tradeBookList) {
    this.tradeBookList = tradeBookList;
}    

public List<MddMeasurementClassVO> getMeasurementClassList() {
    return measurementClassList;
}

public void setMeasurementClassList(List<MddMeasurementClassVO> MeasurementClassList) {
    this.measurementClassList = MeasurementClassList;
}   


public Integer getProfileClassId() {
    return profileClassId;
}

public void setProfileClassId(Integer ProfileClassId) {
    this.profileClassId = ProfileClassId;
}

public String getMeasurementClassId() {
    return measurementClassId;
}

public void setMeasurementClassId(String MeasurementClassId) {
    this.measurementClassId = MeasurementClassId;
}

public Integer getCurveId() {
    return curveId;
}

public void setCurveId(Integer CurveId) {
    this.curveId = CurveId;
}

public Integer getCustomerId() {
    return customerId;
}

public void setCustomerId(Integer customerId) {
    this.customerId = customerId;
}

public Date getOfferFromDate() {
    return offerFromDate;
}

public void setOfferFromDate(Date OfferFromDate) {
    this.offerFromDate = OfferFromDate;
}

public Date getOfferToDate() {
    return offerToDate;
}

public void setOfferToDate(Date OfferToDate) {
    this.offerToDate = OfferToDate;
}

public Integer getTradeBookId() {
    return tradeBookId;
}

public void setTradeBookId(Integer tradeBookId) {
    this.tradeBookId = tradeBookId;
}

public Map<String, String> getManagers() {
    return managers;
}

public void setManagers(Map<String, String> managers) {
    this.managers = managers;
}

public OfferSitesVO getSelectedSite() {
    return selectedSite;
}

public void setSelectedSite(OfferSitesVO selectedSite) {
    this.selectedSite = selectedSite;
}

public OfferSitesVO[] getSelectedSites() {
    return selectedSites;
}    

public List<MpanVO> getSiteMpans() {
    return siteMpans;
}

public void setSiteMpans(List<MpanVO> siteMpans) {
    this.siteMpans = siteMpans;
}

public String getCopcOfferSelection() {
    return copcOfferSelection;
}

public void setCopcOfferSelection(String copcOfferSelection) {
    this.copcOfferSelection = copcOfferSelection;
}

public String getComcOfferSelection() {
    return comcOfferSelection;
}

public void setComcOfferSelection(String comcOfferSelection) {
    this.comcOfferSelection = comcOfferSelection;
}

public Map<String, String> getCotOfferTypes() {
    return cotOfferTypes;
}

public void setCotOfferTypes(Map<String, String> cotOfferTypes) {
    this.cotOfferTypes = cotOfferTypes;
}

public String getCotOfferSelection() {
    return cotOfferSelection;
}

public void setCotOfferSelection(String cotOfferSelection) {
    this.cotOfferSelection = cotOfferSelection;
}

public Date getExpiryDate() {
    return expiryDate;
}

public void setExpiryDate(Date expiryDate) {
    this.expiryDate = expiryDate;
}

public SelectItem[] getCotOfferList() {
    return cotOfferList;
}

public void setCotOfferList(SelectItem[] cotOfferList) {
    this.cotOfferList = cotOfferList;
}

private void loadProfileClass() {     

    FacesMessage msg = null;
    try{
        log.debug("ProfileClass: Start");

            IOffersBean offerBean = BeanInstanceLocator.getOffersBean();                
            List ProfileClassLista = offerBean.getProfileClassList(offerHH_NHH);                

            this.setProfileClassList((ArrayList<ProfileClassVO>) ProfileClassLista);                

            if(ProfileClassLista == null){
                msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,"There are not Profile_class elements",null);
                FacesContext.getCurrentInstance().addMessage(null, msg);                     

        } 
        log.debug("ProfileClassLista: end");

    }catch(Exception e){
        msg = new FacesMessage("ERROR "+e.getMessage());   
        FacesContext.getCurrentInstance().addMessage(null, msg);   
        log.error("ERROR 2:: "+e.getMessage());
    }   
}


private void loadMeasurementClass() {     

    FacesMessage msg;
    try{
        log.debug("MeasurementClass: Start");

            IOffersBean offerBean = BeanInstanceLocator.getOffersBean();
            List MeasureClassList = offerBean.getMeasurementClassList();                      

            this.setMeasurementClassList((ArrayList<MddMeasurementClassVO>) MeasureClassList);

            if(measurementClassList == null){
                msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,"There are not Measurement_class elements",null);
                FacesContext.getCurrentInstance().addMessage(null, msg);  
        }
        log.debug("loadMeasurementClass: end");            

    }catch(Exception e){
        msg = new FacesMessage("ERROR "+e.getMessage());   
        FacesContext.getCurrentInstance().addMessage(null, msg);   
        log.error("ERROR 2:: "+e.getMessage());
    }
}

}

4

1 回答 1

0

我已将一个请求范围 bean 注入另一个视图范围 bean

你不能将一个 bean 注入到另一个范围更广的 bean 中。

作为一项规则,以下可憎的行为是不允许的:)

  1. @RequestScoped>>@ViewScoped

  2. @ViewScoped>>@SessionScoped

  3. @SessionScoped>>@ApplicationScoped

编辑(根据您的更新):注入 bean 的属性,而不是注入 bean 本身,将导致静态注入。静态注入意味着注入目标的值是注入时可用的值。作为执行以下行的时间:

@ManagedProperty(value="#{selectOfferMpans.selectedSites}")

selectedSites一片空白。所以你应该在那里做的是注入整个bean

@ManagedProperty(value="#{selectOfferMpans}")

这样,您就可以访问您感兴趣的任何变量的当前值

于 2013-06-24T13:16:12.680 回答