I have a problem with the JSF selectOneMenu.
Here is my menu:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<ui:composition template="./../WEB-INF/templates/templateLC.xhtml">
<ui:define name="headtags">
<title>Title</title>
</ui:define>
<ui:define name="left">
<ui:include src="./../WEB-INF/templates/userCenterNavigation_left.xhtml"/>
</ui:define>
<ui:define name="content">
<h:form>
<table>
<tr>
<td>Kategorie:</td>
<td><h:selectOneMenu value="#{zbnEditController.zbnCategory}">
<f:selectItems value="#zbnEditController.zbnCategoryMap}"/>
</h:selectOneMenu>
</td>
</tr>
</table>
<br />
<h:commandButton value="Hinzufügen" action="#{zbnEditController.doSave()}" />
<h:commandButton value="Abbrechen" action="index.xhtml?faces-redirect=true" />
</h:form>
This is a part of my template:
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet name="/css/newCssLayout.css"/>
<ui:insert name="headtags" />
</h:head>
This is my Bean with the Map property:
@Named
@SessionScoped
public class ZbnEditController implements Serializable {
@Inject
private ZbnCategoryService zbnCategoryService;
.
.
.
private Map<String,ZbnCategory> zbnCategoryMap = new HashMap<>();
//Getter & Setters...
public void doSave(){
//persist Entity Code
}
public void loadZbnCategoryMap(){
getZbnCategoryMap().clear();
List<ZbnCategory> zbnCategoryList = zbnCategoryService.getAllZbnCategorys();
for(ZbnCategory zbnCategoryInList : zbnCategoryList){
zbnCategoryMap.put(zbnCategoryInList.getZbnCategoryName(), zbnCategoryInList);
}
}
}
Before the page is rendered, a Controller, calls loadZbnCategoryMap() and fills the map with the String and the object.
There are no nested forms, no ui component has a rendered=false attribute and I included the "h:head" tag instead of "head".
If I use the code above and click the commandButton, the doSave() method IS NOT called. If I remove the h:selectOneMenu, everything works fine.
I don´t know how I can solve this problem. Can someone help please?