0
votes

I'm trying to access a Bean in my xhtml files by

<h:commandButton value="Add Recipe" action="#{recipeBean.newres}"/>

, which is working fine (the managedbean class name is also "RecipeBean"). Since I decided to do my project in german language, I wanted to change the name to "RezeptBean", which ended up in refactoring the Java-Class to "RezeptBean" and me adjusting in the xhtml to

<h:commandButton value="Add Recipe" action="#{rezeptBean.newres}"/>

I am really confused, since now the click on the button ends up in "Target unreacheable, identifier resolved to null", whereas the use of "recipeBean.newres" is still working. I think there might be a mapping of the managedbean names to their xhtml-pendant. Does anyone have a clue for me?

Btw, this is the Managedbean-Class:

@SessionScoped
@ManagedBean
public class RezeptBean {
    private Recipe recipe;

    public RezeptBean(){
        recipe = new Recipe();
    }

    public String review(){
        return("recipe");
    }
...
1
Do you have beans.xml or faces-config.xml in your project? - MGorgon
Did you try Clean and Rebuild? - helderdarocha
Tried already Clean and Rebuild. I got the following files: faces-config.xml which is empty and I don't have a beans.xml - schneiti
Did you try restart the container? - nosnhoj

1 Answers

1
votes

Since I decided to do my project in german language, I wanted to change the name to "RezeptBean", which ended up in refactoring the Java-Class to "RezeptBean" and me adjusting in the xhtml to

Why change the Bean name and refactor the code again.?

You can use the name attribute on @ManagedBean[link] annotation.

That way you can keep the BeanName solid and change the Exposed ManagedBean name any time you require.

Example:

@SessionScoped
@ManagedBean(name="rezeptBean")
public class RecipeBean{
....
....
}