1

I inject bean selectOfferMpans in other bean

@ManagedProperty(value="#{selectOfferMpans}")
private SelectOfferMpans selectOfferMpans;    

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

If I ask for the value of selectOfferMpans.selectedSites in @PostConstruct of the second bean , the debugger says it's null.

This property was updated in this action of the 1.xhtml

<p:commandButton id="pCBFind" styleClass="centerAbs" type="submit" icon="ui-  icon-search" value="#{text['selectOfferMpans.find']}" actionListener="#{selectOfferMpans.findCustomer}" update="CustomerData,CustomerSites" oncomplete="expandAll();"/>

Then when the user clicks this button the application navigates from the to 1.xhtml to the 2.xhtml

p:commandButton id="pCBCreateOffer" type="submit" icon="ui-icon-check" value="#{text['selectOfferMpans.newOffer']}"
                    action="#{selectOfferMpans.goToOffers}"/>

code from bean1

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;
    }
}                  

What am I missing?

  • what scopes do the beans have? as you are navigating to another page @ViewScoped would not work for example – Przemek Jun 27 '13 at 13:50
  • Both beans are `@ViewScoped`. Well, it works for other properties(the ones updated in `@PostConstruct` on the bean1) of the same bean but not for this property `selectedSites`. – user2366464 Jun 28 '13 at 06:18
  • as you navigate to the next page, the bean of the first page is destroyed, because of the `@ViewScoped` bean. So when you call the selectedSites of the first bean in your second bean they do not exist any more, therefore they are null. you have to pass them on another way to the second bean – Przemek Jun 28 '13 at 13:45
  • OK, that makes sense. How could I pass that property bean? – user2366464 Jun 28 '13 at 15:26
  • Look at this http://stackoverflow.com/questions/4994458/how-can-i-pass-a-parameter-to-a-commandlink-inside-a-datatable – Przemek Jun 28 '13 at 15:29

0 Answers0