I'm facing some issue that doesn’t make sense to me. I'm getting an "identifier resolved to null" when trying to use a selectOneMenu in a jsf page.
I do know this happens when the controller is not being resolved or the field is null, however: i) if I remove the selectOneMenu, everything works fine (including other fields binding to attributes of the same controller); ii) the field target of my selectOneMenu is a non-null String. Here is my code:
<h:selectOneMenu id="brandAccess" value="#{myController.field}" title="" >
<f:selectItem itemValue="Item1" itemLabel="Item1" />
<f:selectItem itemValue="Item2" itemLabel="Item2" />
<f:selectItem itemValue="Item3" itemLabel="Item3" />
</h:selectOneMenu>
Controller:
@ManagedBean(name = "myController")
@SessionScoped
public class MyController implements Serializable {
private String field; //Makes no difference with new String()
public void setField(String field) { this.field = field; }
public String getField() { return this.field; }
}
Edit:
The indicated question leads to two possible roots:
1) controller is null, not accessible or wrongly defined in the xhtml file: this is not the case. If I remove this particular component, everything else works fine.
2) Field doesn't exist or is null: Not the case, also. The field does exist and it is not null. Also, tried creating a new field and it is still not working
Update
For whoever is having the same issue with Spring and JSF: I cannot answer as the question was marked as duplicated. My case was a bit different from the ones related to the other question: the issue was that Spring wasn't creating my controller. For some reason, the error doesn't occur with h:inputText
for example, but it does with h:selectOneMenu
. Fixing is quite simple: just annotate the controller with @Controller
(even though this is not a Spring Controller) and Spring will do the rest of the work.