我有以下简单的 selectOneMenu
<h:selectOneMenu id="shop" styleClass="tcell"
value="#{shoppingcenterControler.shoppingCenterScreenBean.shoppingcenterName}"
onchange="submit()"
valueChangeListener="#{shoppingcenterControler.shopChooseAction}">
<f:selectItem itemValue="#{option.defaultShoppingcenter}" itemLabel="#{option.defaultShoppingcenter}"></f:selectItem>
<f:selectItems value="#{shoppingCenterScreenBean.shoppingcenternames}"></f:selectItems>
</h:selectOneMenu>
当我在上使用@Named
注释时,shoppingcenterControler
我收到一条javax.el.PropertyNotFoundException
警告我Target Unreachable, identifier 'shoppingcenterControler' resolved to null
。
当我使用@ManagedBean
注释时,我收到警告:Property 'shopChooseAction' not found on type com.manageMyShopping.presentation.controler.ShoppingcenterControler
,shopChooseAction
虽然不是属性,但它是:
public void shopChooseAction(ValueChangeEvent event){
String shopName = getShoppingCenterScreenBean().getShoppingcenterName();
if (!shopName.equals(defaultShopp)) {
for (ShoppingCenterScreenBean thisShop : Shoppinglistcontroler.getShoppinglistScreenBean().getShoppingCentersScreenBean()) {
if (!thisShop.getShoppingcenterName().equals(shopName)) {
ShoppingCenterScreenBean newShoppingcenter = new ShoppingCenterScreenBean();
newShoppingcenter.setShoppingcenterName(shopName);
ShoppinglistScreenBean shoppinglist = Shoppinglistcontroler.getShoppinglistScreenBean();
shoppinglist.getShoppingCentersScreenBean().add(newShoppingcenter);
}
}
}
}
我查看了不同的链接,包括以下内容: 一个类似的问题
但是,它既不适合我,也不喜欢伪造的解决方案。我正在寻找一个真正的解决方案,我想了解
- 为什么
@Named
注释没有按预期运行?我已将相应的依赖项添加到pom.xml
我的项目文件中。 - 为什么
valueChnageListener
要提高PropertyNotFoundException
方法的名称?
非常感谢任何帮助。
我的环境:Fedora 24、Java 1.8、apache-tomcat 8.0.33,我使用的是 Eclipse Mars。