0

我已经用 Primefaces 苦苦挣扎了几天,DataTable 在编辑一行后没有显示新值。

我进行了很多搜索,但找不到解决方案。

所以任何人都可以帮助我......谢谢

html代码是

<h:form id="form">
            <div id="nav">
                <ui:insert name="commonHeader">
                    <ui:include src="templates/commonHeader.xhtml" />
                </ui:insert>
            </div><br/><br/>

            <div class="container" style="margin-top: 50px;">
            <p:commandButton value="Add New Project" action="AddProject.xhtml?faces-redirect=true"></p:commandButton>
            <br/>
            <br/>
            <p:dataTable id="db" var="rows" rowKey="#{rows.id}" editable="true"
                value="#{projectBean.list}">
                <f:facet name="header">
                    <h:outputLabel value="Project Details"></h:outputLabel>
                </f:facet>
                <p:ajax event="rowEdit" listener="#{projectBean.onRowEdit}"
                        update=":form:db" />
                <p:ajax event="rowEditCancel"
                        listener="#{projectBean.onRowCancel}" update=":form:db" />
                <p:column headerText="ID" style="width:32px">
                    <p:outputLabel value="#{rows.id}"></p:outputLabel>
                </p:column>
                <p:column headerText="Project Title" filterBy="#{rows.title}" filterMatchMode="contains">
                    <p:cellEditor>
                        <f:facet name="output">
                        <p:commandLink action="#{projectBean.openProjects(rows)}"
                                    process="@this" immediate="true">
                                    <p:outputLabel value="#{rows.title}"></p:outputLabel>
                        </p:commandLink>

                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{rows.title}" style="width:100%"
                                    required="true" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Project Description" filterBy="#{rows.description}" filterMatchMode="contains">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{rows.description}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{rows.description}" style="width:100%"
                                required="true" valueChangeListener="projectBean.newd" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Insertion TimeStamp">
                    <p:outputLabel value="#{rows.insertionTimestamp}"></p:outputLabel>
                </p:column>
                <p:column headerText="Close TimeStamp">
                    <p:outputLabel value="#{rows.closeTimestamp}"></p:outputLabel>
                </p:column>
                <p:column style="width:64px">
                    <p:rowEditor />
                </p:column>
                <p:column style="width:100px;text-align: center;" >
                <p:commandLink value="Delete">
                    <p:ajax update="db" listener="#{projectBean.deleteProj(rows)}"></p:ajax>
                </p:commandLink>
            </p:column>
            </p:dataTable>
            </div>
        </h:form>

但是当调用 rowEdit 事件时,我无法在函数 onRowEdit(RowEditEvent event) 中获取新值

Bean函数如下

public void onRowEdit(RowEditEvent event) {
        try {
            stub = new BusinessServiceStub();
            UpdateProjectRecord PARAM = new UpdateProjectRecord();
            PARAM.setArg0((Project) event.getObject());
            UpdateProjectRecordE reques = new UpdateProjectRecordE();
            reques.setUpdateProjectRecord(PARAM);
            UpdateProjectRecordResponseE response = stub
                    .updateProjectRecord(reques);
            UpdateProjectRecordResponse responseRecive = response
                    .getUpdateProjectRecordResponse();
            int result = (responseRecive.get_return());
            if(result>0){

            }
        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
4

0 回答 0