0
votes

I used a lot the primefaces datatable with row editable but here I am stuck with it. The datatable is correctly displaying but when I click the edit button, the datatable turn into the editable mode and here I can only use the cancel button of . The save button do nothing and I still rest in editable mode when I click it. (and the bean action not called).

Here is the code

<p:dataTable value="#{bean.days}" var="days" editable="true">

    <p:ajax event="rowEdit" listener="#{bean.changeCell}"/>
    <p:ajax event="rowEditCancel" listener="#{bean.changeCell}"/>

    <p:column headerText="my header">
        <p:cellEditor>  
            <f:facet name="output" >
                <h:outputText value="#{days.get(4).date}" >
                    <f:convertDateTime pattern="dd/MM" timeZone="CET" />
                </h:outputText>
            </f:facet>
            <f:facet name="input">
                <p:calendar value="#{days.get(4).date}" locale="fr" mindate="#{jours.get(0).date}" pattern="dd/MM"/>
            </f:facet>  
        </p:cellEditor>
    </p:column>

    ... other columns

    <p:column>
        <p:rowEditor />
    </p:column>
</p:dataTable>

And a part of the bean

@ManagedBean(name = "bean")
@ViewScoped
public class MyBean {

    private List<List<MyDays>> days; // with getters and setters

    @PostConstruct
    public void init() {
        // Filling the list
    }

    public void changeCell(RowEditEvent event) {
        List<MyDays> j = (List<MyDays>)event.getObject();
        System.out.println("here");
    }

}
1

1 Answers

0
votes

It's ok now. In fact I was using the getter to access my list data and it's a mistake.

I changed this

<p:calendar value="#{days.get(4).date}" locale="fr" mindate="#{jours.get(0).date}" pattern="dd/MM"/>

into this

<p:calendar value="#{days[4].date}" locale="fr" mindate="#{jours[0].date}" pattern="dd/MM"/>