Problems with p: editable datatable

0

Good evening. I'm having trouble updating an editable datatable I created here. It reads the values, but does not assign them to the ManagedBean object so I can persist.

Follow the Bean Code

public void onCellEdit(CellEditEvent event) {
    Object oldValue = event.getOldValue();
    Object newValue = event.getNewValue();

    if (newValue != null && !newValue.equals(oldValue)) {
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue);
        FacesContext.getCurrentInstance().addMessage(null, msg); 
    }
}

public void prepararIndicadores() {
    indicadoresUsuario = new ArrayList<>();
    IndicadorAmbiental iamb ;

    for(IndicadorAmbiental ia : getIndicadores()) {
        iamb = new IndicadorAmbiental();

        iamb.setDescricao(ia.getDescricao());
        indicadoresUsuario.add(iamb);
    }
}

public void cadastrarIndicadores() {
    for(IndicadorAmbiental ia : indicadoresUsuario) {
        ia.setAno(anoFinal);
        ia.setCenario(cenario);

        //indicadorAmbientalDAO.salvar(ia);
    }
}

View Code

    <p:dataTable var="i" value="#{cenarioBean.indicadoresUsuario}"
        paginator="true" rows="15" class="dataTable" id="dataTable" editMode="cell"
        emptyMessage="Nenhum Indicador Cadastrado" widgetVar="indicadores"
        paginatorPosition="bottom" editable="true" >

        <p:ajax event="cellEdit" listener="#{cenarioBean.onCellEdit}" /> 

        <p:column headerText="Nome" styleClass="column">
            <h:outputText value="#{i.descricao}" />
        </p:column>

        <p:column headerText="Valor" styleClass="column" width="300">
            <p:cellEditor> 
                <f:facet name="output"><h:outputText value="#{i.valor}"/></f:facet> 
                <f:facet name="input"><p:spinner value="#{i.valor}" stepFactor="0.5" size="47" styleClass="componentePF text" /></f:facet>  
            </p:cellEditor>
        </p:column>
    </p:dataTable>

Editing the fields opens, but does not allow me to make changes. If anyone can give a light, thank you!

    
asked by anonymous 09.01.2016 / 03:49

1 answer

0

Make sure the dataTable code is within one and if the attributes of the class used have getters and setters

    
12.01.2016 / 12:18