0

i'm having a column with auctions' name like this:

        <rich:column sortBy="#{auct.name}" sortOrder="ascending" >
            <h:outputLink value="detailEnglishType.xhtml?auctionId=#{auct.id}" rendered="#{auct.auctionTypes eq 'ENGLISH'}">#{auct.name}</h:outputLink>
            <h:outputLink value="detailDutchType.xhtml?auctionId=#{auct.id}" rendered="#{auct.auctionTypes eq 'DUTCH'}">#{auct.name}</h:outputLink>
        </rich:column>

and after the GET request happens, in destination page:

<ui:define name="view">
    <f:metadata>
        <f:viewParam name="auctionId" rendered="#{auctionManager.currentAuction != null}"
            value="#{currentAuction.init(auctionId)}" />
    </f:metadata>
</ui:define>

and the init method from the AuctionBean(it's ViewScoped, Stateful):

    public void init(long auctionId) {
    if (auctionId == 0) {
        String message = "Bad request.";
        FacesContext.getCurrentInstance().addMessage(null, 
            new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
        return;
    }

    this.currentAuction = em.find(Auction.class, auctionId);

}

and the get method:

@Produces
@Named
@CurrentAuction
@Dependent
@PermitAll
public Auction getCurrentAuction() {
    if (currentAuction != null && em.contains(currentAuction)) {
        currentAuction = em.merge(currentAuction);
    }
    return currentAuction;
}

what happens is that the currentAuction is NULL after the GET request, not being set at all. I can t use @PostConstruct because i'm using CDI Beans.

Anyone any idea, please ? I'm really struggling with this issue...

Thanks

Nica
  • 55
  • 9
  • Can you please take a look at this answer http://stackoverflow.com/a/6377957/1144326 – Ouerghi Yassine May 08 '17 at 09:39
  • There is nothing like this : ViewScoped & Statefull. Statefull = EJB, not a (container) managed bean. The application of stateless beans (if transaction & security is a concern) & session/conversation scoped CDI beans is a more flexible solution then SFSBs. – The Bitman May 08 '17 at 11:30

0 Answers0