I have a Webapp with the Technologies: Wildfly, JSF, Primefaces
I have to select One Menus. The first Select One Menu loads all Warehouses and the second Select One Menu loads all Products which depends to the selected Warehouse.
I want to implemente the posibility, that i don't have necessarily choose a warehouse. I want to have the possibility that i dont select a warehouse, and logically if i dont choose a warehouse, the product Select one menu has to be disabled.
If i submit the form without a warehouse, it should be written in the database null for warehouse and also null for product.
My first attempt was to do the following entry in the select one menu of warehouse.
<f:selectItem itemLabel="---" itemValue="#{null}" value="#{null}"/>
Now, i don't know how to set the value of the warehouse select one menu to null, if i haven't choose a warehouse.
value="#{warehouseDataActions.actualWarehouse}" --> how to set to null
The second Problem is, that in the Ajax of the first select one menu i have to add the Attribute immediate = true. This Attribute is only neccassary for me if i add the following line. I don't know why ?
<f:selectItem itemLabel="---" itemValue="#{null}" value="#{null}"/>
So i have three questions:
1-How to set the actualWarehouse and .actualWriteservice.warehouseProduct to null ?
How to disable the product select one menu if i have already doesn not choose a warehouse (---) above ?
Why does my Ajax request in the warehouse select one menu does not function, if i add the item
<p:selectOneMenu style="width:151px" value="#{warehouseDataActions.actualWarehouse}"> <f:converter converterId="ccWarehouseConverter" /> <f:selectItem itemLabel="---" itemValue="#{null}" value="#{null}"/> <f:selectItems value="#{warehouseDataActions.allWarehousesForProject}" var="warehouse" itemLabel="#{warehouse.warehouseName}" itemValue="#{warehouse}" /> <p:ajax listener="#{warehouseProductDataActions.warehouseProductsForWarehouse}" update="products" />
<p:panelGrid> <p:outputLabel for="products">#{texts['writeservice.product']}</p:outputLabel> <p:selectOneMenu id="products" style="width:151px" value="#{writeserviceDataActions.actualWriteservice.warehouseProduct}"> <f:converter converterId="ccWarehouseProductConverter" /> <f:selectItems value="#{warehouseProductDataActions.warehouseProductsResult}" var="warehouseProduct" itemLabel="#{warehouseProduct.product.productName}" itemValue="#{warehouseProduct}" /> </p:selectOneMenu> </p:panelGrid>