Search code examples
eclipsejsfmanaged-bean

Name property in @ManagedBean annotation is not available


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?


Solution

  • @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