1

I am working with JSF 2.2 for a warehouse. A warehouse has many box and each box has many products. The total number of products per box must be to save in its box respective and the total of products of all boxes must be to save in the warehouse.

I am trying with the next code, user writes the number of box of the warehouse. When the user writes on myBean.warehouse.numBox the system instances the boxes list and the products lists for each box. After the system updates the pg_ProductsEachBox panelGroup.

In pg_ProductsEachBox, with each value in the product.quantity the system updates the total per box and warehouse calling to myBean.updateQuantities.

My problem is when the user writes in myBean.warehoyse.numBox and the system updates pg_ProductsEachBox the <f:ajax event="change" listener="#{myBean.updateQuantities}" execute="product_#{box.idBox}" render="pg_ProductsEachBox"/> is activated and launch an alert (javascript) with the next message: serverError: class javax.faces.FacesException Invalid search product_1 expression product_1 doesn't exist referring to product_#{box.idBox}.

Thank you!

<h:panelGroup id="pg_NumBox">
    <b:inputText type="number" required="true" value="#{myBean.warehouse.numBox}">
        <f:ajax event="change" listener="#{myBean.updateListBoxesAndListProducts}" execute="pg_NumBox" render="pg_ProductsEachBox"/>
    </b:inputText>
</h:panelGroup>


<h:panelGroup id="pg_ProductsEachBox">
    <b:inputText type="number" required="true" value="#{myBean.warehouse.TotalProductsAllBoxes}" readonly="true"/>
    <ui:repeat value="#{myBean.listBoxes}" var="box">
        <b:inputText type="number" required="true" value="#{box.quantity}" readonly="true"/>
        <ui:repeat value="#{myBean.listProductsForBox(box.idBox)}" var="product">
            <h:panelGroup id="product_#{box.idBox}">
                <b:inputText type="number" required="true" value="#{product.quantity}">
                    <f:ajax event="change" listener="#{myBean.updateQuantities}" execute="product_#{box.idBox}" render="pg_ProductsEachBox"/>
                </b:inputText>
            </h:panelGroup>
        </ui:repeat>
    </ui:repeat>
</h:panelGroup>
Juan Camacho
  • 736
  • 2
  • 7
  • 15

0 Answers0