Question

I have this p:dataTable

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"> 
<h:form id="form" prependId="false">
    <p:dataTable var="row" id="list" value="#{BB.dataTable}" rowIndexVar="i">
        <p:column headerText="#{bundle['id']}">
            <h:outputText value="#{row.id}" />
        </p:column>
        <p:columns var="fecha" value="#{BB.lFechaEntradaVigor}">
            <f:facet name="header">
                <h:outputText value="#{fecha}" />
            </f:facet>
            <h:outputText value="#{row.getCoste(fecha)}" styleClass="#{row.isValido(fecha)?'vigor':''}" rendered="#{!row.isUpdatable(fecha)}">
                <f:convertNumber groupingUsed="true" minFractionDigits="2" />
            </h:outputText>
            <pe:inputNumber value="#{BB.valor}" rendered="#{row.isUpdatable(fecha)}" >
                <p:ajax event="change" listener="#{BB.changeValor(fecha, row, i)}" />
            </pe:inputNumber>
        </p:columns>
    </p:dataTable>
    <p:commandButton value="#{bundleComunes.guardar}" action="#{BB.saveData()}" />
</h:form>

When I call changeValor valor always return null, but when I write pe:inputNumber out of p:columns works.
Any idea???

Was it helpful?

Solution

Binding one backing bean attribute to many input fields seems weird to me. Try passing the component value as an argument to changeValor():

<pe:inputNumber value="#{BB.valor}" rendered="#{row.isUpdatable(fecha)}" >
    <p:ajax event="change" listener="#{BB.changeValor(component.value, fecha, row, i)}" />
</pe:inputNumber>

Or better yet use a remote command. Place the following outside your table:

<pe:remoteCommand name="changeValor" 
    process="@this" 
    actionListener="#{BB.changeValor}" 
    global="false" 
    partialSubmit="true">
    <pe:methodSignature parameters="java.lang.String, java.lang.String, java.lang.String, java.lang.String" />
    <pe:methodParam name="valor" />
    <pe:methodParam name="fecha" />
    <pe:methodParam name="row" />
    <pe:methodParam name="i" />
</pe:remoteCommand>

Don't forget to corrent the parameter types.

Now the markup for the inputNumber:

<pe:inputNumber value="#{BB.valor}" rendered="#{row.isUpdatable(fecha)}"  onchange="changeValor(this.value, #{fecha}, #{row}, #{i})" />
</pe:inputNumber>

OTHER TIPS

try to do like this :

   <pe:inputNumber value="#{BB.valor}"
decimalSeparator="," decimalPlaces="2" thousandSeparator="." emptyValue="0"
id="id1" style="width:100px" />

the solution is for example

  <p:inputNumber id="haberNumber" value="#{diarioController.haber}" >
                        <p:ajax update="haberNumber" />
</p:inputNumber>

work fine!!!

<pe:inputNumber autocomplete="off" ... />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top