0

I have a project in JSF, I try to use @ Inject to use variables from a JSF page on another JSF page. I have a main JSF Entity, in which I use the @Inject and a method to send these variables. So here's the code:

 @Inject private updateDominio update;
 public void actualizar(ActionEvent actionEvent) {
    dominio = (TblDominios)getDataTable1().getRowData();
    update = new updateDominio();
    update.setDominio(dominio);
    try {
        FacesContext.getCurrentInstance().getExternalContext().redirect("updateDominio.xhtml");
    } catch (IOException e) {

    }
}

In the other hand, here's the destination entity:

@Named
@ManagedBean
@Scope("session")

public class updateDominio {

private TblDominios dominio;


public updateDominio() {
    //super();
    //this.dominio = new TblDominios();
    System.out.println(dominio);
}


public void setDominio(TblDominios dominio) {
    this.dominio = dominio;
    System.out.println(dominio);

}

public TblDominios getDominio() {
    return dominio;
}   

}

My problema is that in the method setDominio they arrive the values of the another Entity, but when i use this values in the JSF:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></meta>
</head>
<body>
    <h:form>
        <h:outputLabel value="Nombre"/>
        <h:inputText value="#{updateDominio.dominio.strDescripcion}"/>

    </h:form>
</body>

This doesn't display anything, I don't know what happen. thank you for you help.

I'm sorry for my bad english :c

Andres
  • 1
  • 1
  • Please read https://stackoverflow.com/questions/18387993/spring-jsf-integration-how-to-inject-a-spring-component-service-in-jsf-managed – Kukeltje Sep 22 '17 at 18:10
  • Possible duplicate of [Spring JSF integration: how to inject a Spring component/service in JSF managed bean?](https://stackoverflow.com/questions/18387993/spring-jsf-integration-how-to-inject-a-spring-component-service-in-jsf-managed) – Kukeltje Sep 22 '17 at 18:26

1 Answers1

0

Do not mix JSF and CDI annotations.

@Named //CDI
@ManagedBean  //JSF
@Scope("session")

Use pure CDI like this:

@Named
@SessionScope //javax.enterprise.context.SessionScoped

Or use JSF like this:

@ManagedBean
@SessionScope //javax.faces.bean.SessionScoped

Remember that:

  • to inject CDI use @Inject
  • to inject JSF managed beans, use @ManagedProperty
C.P.O
  • 1,213
  • 2
  • 11
  • 29
  • It's even a mix of jsf, cdi and SPRING annotations. But there is a 'duplicate' Q/A of all this https://stackoverflow.com/questions/18387993/spring-jsf-integration-how-to-inject-a-spring-component-service-in-jsf-managed – Kukeltje Sep 22 '17 at 18:08