How to calculate amount in primefaces jsf with ajax?

0

I need to calculate the amount of products that are in a dynamic datatable I am using the edit property of datatable jsf.

the multiply fields are the price by the amount = amount.

the price is an outputlabel, the quantity is inputtext, and the amount where the result would throw me should be a label.

Greetings

introducir el código aquí
 <p:dataTable emptyMessage="NO SE ENCONTRO DATOS" id="mitable0" rendered="#{not empty ingreso.milista}"
     sortBy="#{kk14.des_categoria}" style="width: 100%;font-size: 0.7em;"  
     value="#{ingreso.milista}" var="kk14" rowIndexVar="row"
     editable="true" editMode="cell">       

     <p:headerRow>
        <p:column colspan="6">
            <h:outputText value="#{kk14.des_categoria}" />
        </p:column>
    </p:headerRow>

        <p:column  width="50%" headerText="NOMBRE PRODUCTO"><h:outputLabel value="#{kk14.des_producto}"/></p:column>
        <p:column  width="10%" headerText="UN MEDIDA"><h:outputLabel value="#{kk14.un_medida}"/></p:column>
        <p:column   width="10%" headerText="PRECIO UNITARIO" id="precio">
        <h:outputLabel value="#{ingreso.formatearNumeros(kk14.precio_unitario)}"/>
        </p:column>        
        <p:column  width="10%" headerText="CANTIDAD">


           <p:cellEditor>
           <f:facet name="output"><h:outputText  value="#{kk14.cantidad}" >

               </h:outputText></f:facet>
           <f:facet name="input">

                <p:inputNumber  minValue="0.00" value="#{kk14.cantidad}" style="width:96%" decimalPlaces="2"> 
              <p:ajax event="keyup" update="importe[#{row +1}]" listener="#{ingreso.handleKeyEvent}"/>

               </p:inputNumber>                   

           </f:facet>
           </p:cellEditor>
        </p:column>   
        <p:column  width="10%"  headerText="IMPORTE">

            <h:outputText id="importe[#{row +1}]" value="#{kk14.importe}"/>



        </p:column>
        <p:column  width="10%" headerText="OBSERVACION">
        <p:cellEditor>
            <f:facet name="output"><h:outputText value="#{kk14.observacion}" /></f:facet>
            <f:facet name="input"><p:inputText value="#{kk14.observacion}" style="width:96%"/>  </f:facet>

       </p:cellEditor>
       </p:column>



        </p:dataTable>

on the bean:

public void handleKeyEvent() {

 objAreaProducto.getImporte();
}

in my model:

public double getImporte() {
    return importe;
}

public void setImporte() {

    this.importe = precio_unitario * cantidad;

}
    
asked by Raúl Eduardo Chávez Espinoza 23.03.2018 в 16:30
source

0 answers