This example is from JSF: The Complete Reference . I am currently reading the book and have been stuck here.
Read page 156 of the book , under heading "Using a Value Change Event to Auto-Fill Fields"
You will see the same example here.
As far as explanation for #{city.name} not getting updated is given, I think you are right but I missed one point. The valueChangeListener written for Zipcode calls responseComplete() , so there is not question of going to 4th phase. Can you guide me now how do I use managed bean here ?
As far as this is concerned :
Here you're misusing the valueChangeListener to set the value of another component instead of handling the actual change of the value (you're not interested in the old value). Here you're also misusing the immediate attribute to bypass validation (and model update!) of the other components.
I think you are wrong ? I can use the old value and new value of the zip code to do some comparison , after all every city can have many zip codes not one. So I can determine whether or not to change the value of the city field based on zip code.
Also if this book has almost the same code which I have written, so is this book wrong or I need to use some other book.