I have the following simple 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>
When I use @Named
annotation on shoppingcenterControler
I receive a javax.el.PropertyNotFoundException
warning me Target Unreachable, identifier 'shoppingcenterControler' resolved to null
.
When I use @ManagedBean
annotation I receive the warning: Property 'shopChooseAction' not found on type com.manageMyShopping.presentation.controler.ShoppingcenterControler
, whlie shopChooseAction
is not a property, it is:
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);
}
}
}
}
I have looked different links including the following: One somehow similar question
However, it neither worked for me, nor I do like faked solutions. I am searching a real solution and I want to understand
- Why
@Named
annotation is not functioning as it is expected? I have added the corresponding dependency to thepom.xml
file of my project. - Why
valueChnageListener
should raisePropertyNotFoundException
on the name of the method?
Any help is highly appreciated.
My environment: Fedora 24, Java 1.8, apache-tomcat 8.0.33, and I am using Eclipse Mars.