inputText数据不显示在值中

时间:2013-03-05 06:30:40

标签: jsf

数据表:

<h:form>
    <h:panelGroup>
        <h:dataTable id="branch-table" value="#{testController.items}" var="item" border="0" >
            <h:column>
                <f:facet name="header">
                    <h:outputText value="NAME"/>
                </f:facet>
                <h:outputText value="#{item.name}"/>
            </h:column> 
            <h:column>
                <h:inputText value="#{item.name}"/>
            </h:column> 
            <h:column>
                <p:commandButton styleClass="edit" action="#{testController.prepareEdit}" value="" oncomplete="updateForm();"/>
            </h:column>
        </h:dataTable>
    </h:panelGroup>
</h:form>

形式:

<div id="test-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <h:form>
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            Details
        </div>
        <div class="modal-body">
            <h:inputText value="#{testController.edit.name}"/>
        </div>
        <div class="modal-footer">
            <p:commandButton action="#{testController.update}" value="#{bundle.CreateBranchSaveLink}"/>
            <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
        </div>
        <p:remoteCommand name="updateForm" update="@form" oncomplete="$('#test-modal').modal('show');"/>
    </h:form>
</div>

prepareEdit方法:

public void prepareEdit() {
    current = (TestEntity) getItems().getRowData();
    selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
}

编辑方法:

public TestEntity getEdit() {
    if (editCurrent == null) {
        editCurrent = new TestEntity();
        selectedItemIndex = -1;
    }
    return editCurrent;
}

注意表单上的<h:inputText value="#{testController.edit.name}"/>。没有数据会显示,但如果我将其更改为<h:outputText value="#{testController.edit.name}"/>,将显示正确的数据。

我很困惑,为什么会这样。我需要它是inputText所以我可以使用新值更新它。

*更新

getItems方法:

public DataModel getItems() {
    if (items == null) {
        items = getPagination().createPageDataModel();
    }
    return items;
}

0 个答案:

没有答案