I am trying to populate the list of an <h:selectOneMenu>
. However, the list that I am trying to retrieve is part of another class that is a variable in the base class.
Here is what I have and I'm not sure if this is even possible or how to do it.
I have a Citation
class with the following:
public class Citation {
private int id;
private String title;
private Status status;
// getters and setters
}
Then I have a Status
class with the following:
public class Status {
private int id;
private String name;
public List<Status> getAll() {
// goes to the database and gets a list of status objects
System.out.println("I was called!");
}
// getters and setters
}
Then on my xhtml page, I have the following:
<h:selectOneMenu id="citation_status" value="#{citation.status}">
<f:selectItems value="#{citation.status.all}" var="s"
itemLabel="#{s.name}" itemValue="#{s.id}" />
</h:selectOneMenu>
However, this doesn't seem to be calling the getAll
method in the Status
class at all. When the page finishes loading, the select box is empty and the console does not have the output of I was called!
from the getAll()
method.
I'm a bit new to JSF and I've tried searching the best that I can, but I'm not really sure the terminology to use when searching for this because it's not technically called a "subclass", but that's the best name I can come up with, so needless to say, I've come up with nothing from searching.
Additional Information
If it helps:
- I'm using Glassfish as my application server
- I'm using Hibernate for my ORM
- I'm using JSF 2.0