Pregunta

I am trying to make my first JSF application with help of youtube tutorial video. (eclipse/JSF2.0 Dynamic web project). In the first class created, I have to add the below line

@ManagedBean (name = "userRegistration")

But, when I did the same, eclipse shows an error on "name" keyword and giving suggestion to replace it with "value".

@ManagedBean (value = "userRegistration")

But it is not working as expected and threw below error.

/FirstPage.xhtml @10,66 value="#{userRegistration.name}": Target Unreachable, identifier 'userRegistration' resolved to null

Can anyone please help me here?

¿Fue útil?

Solución

@ManagedBean(name="userRegistration") is correct. You can avoid (name="userRegistration") part if your java class is UserRegistration. Check if you have imported proper class: java.faces.bean.ManagedBean

Otros consejos

Piggy backing on previous answer, I just had this problem as well. Make sure you have the correct import. There are 2 imports that have the @ManagedBean annotation.

javax.annotation.ManagedBean & javax.faces.bean.ManagedBean

javax.annotation.ManagedBean does not have the attribute name, or eager for that matter.

I noticed that if I just annotated my bean class with @annotation that it would import the javax.annotation.ManagedBean class and not the faces one that I wanted.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top