Cascading p:selectOneMenu model value not set

China☆狼群 提交于 2019-11-29 12:51:37
BalusC

That can happen if the managed bean is been placed in the request scope by @RequestScoped. Every single HTTP request, including Ajax requests, would create a completely brand new instance of the bean, with all properties set to default. This way the <f:selectItems> list becomes empty and hence there's no value to set in the model.

Placing the bean in the view scope by @ViewScoped should solve this problem.

See also:


Update: you should remove those <managed-bean> definitions from faces-config.xml. That was a leftover from old JSF 1.x way of registering beans. They would only override the JSF 2.x way of @ManagedBean configurations.

Not directly related to your concrete problem, but those <navigation-case> entries are superfluous in JSF 2.x. Perhaps you were incorrectly reading old JSF 1.x books/tutorials/resources instead of JSF 2.x ones?


Unrelated to the concrete problem, you've there seriously a SQL injection attack hole in getTradeReport() method. You should never string-concatenate user-controlled variables in a SQL/JPQL string. Use parameterized queries with setParameter() instead. See also CSRF, XSS and SQL Injection attack prevention in JSF.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!