JSF value change Simple problem
I am having a small difficulty understanding which approach should be used to initialize data in JSF.
Take this simple example:
There is a drop down with 2 items: 1, 2
<h:selectOneMenu value="#{bean.value}"
valueChangeListener="#{bean.change}" onchange="submit()">
<f:selectItem itemLabel="1" itemValue="1"/>
<f:selectItem itemLabel="2" itemValue="1"/>
</h:selectOneMenu>
Now, when page loads, it really shows the second value of the drop down selected.
But, when I simply add a "valueChangeListener" method, I can see that there is a problem:
publicvoid change(ValueChangeEvent event)
{
System.out.println("I was here");
}
Whenever switching from value: 1 to: value: 2, the event is not activate. Since I was setting each time the constructor is built, the value "manually".
The problem gets much deeper when, for exmaple, I would like to show a table that changes according to several filters. Initially the data is loaded on the constructor. But when filter changes, the data should be reloaded. So I load it twice: Once in the constructor, then I have to rebuild data in the event itself.
Am I missing here something ? Or the JSF mechanism is missing somthing ... ;-)

