Essentially the problem is how to control the list of items in a second <p:selectOneMenu/< from the selection made in the first menu. The question comes up frequently enough that I decided to write up a demo application.
The application was developed using NetBeans 7.1.2 and PrimeFaces 3.2 originally. It has been updated to use PrimeFaces 3.3.1 which is the most current at the time of writing. I validated it on GlassFish 3.1.2.
The Apache Maven project can be downloaded from here: primefaces-ajax-selectone.zip
This demo wants the user to pick a state, and then a city. A key problem is not just the update, but not displaying city values if a state is not selected. Also erasing the selected city, if the state has changed.
Hello,
ReplyDeleteI got:
java.lang.NullPointerException
at com.bluelotussoftware.example.jsf.DataBean.stateChangeListener(DataBean.java:159)
I run on glassfish 3.1.2 Do you know maybe reason?
Thank you
This comment has been removed by the author.
ReplyDeleteInterestingly... the exception is being caused by the valueChangeListener="#{dataBean.stateChangeListener(event)}". If you remove the (event), it will start working.
ReplyDeleteThank you:)
ReplyDeletethank you soo much man your code helped me a lot _/\_
ReplyDelete