selectOneMenu更改时选择行

时间:2015-04-10 19:53:32

标签: jsf primefaces

当我更改selectOneMenu的值时,我需要在支持bean中设置行并更新位于同一行的按钮。

<p:dataTable
    id="dataTableId" rowIndexVar="rowIndex" rowKey="#{record.id}"
    rows="10" selection="#{bean.selectedRecord}" selectionMode="single"
    value="#{bean.allRecords}" var="record" widgetVar="dataTableWV">

    <p:column>
        <p:selectOneMenu converter="omnifaces.SelectItemsConverter"
            id="selectOnMenuId" value="#{bean.recordDTO}">
            <f:selectItems
                itemLabel="#{status.name}" itemValue="#{status.id}" value="#{bean.statusList}" var="status" />
            <p:ajax event="change" update="saveButtonId">
                <f:setPropertyActionListener target="#{bean.selectedRecord}" value="#{record}" />
            </p:ajax>
        </p:selectOneMenu>
    </p:column>
    <p:column>
        <p:commandButton action="#{bean.someMethod}" icon="ui-icon-disk" id="saveButtonId" update="someId"/>
    </p:column>
</p:dataTable>

编辑@Tiny建议:

<p:dataTable
    id="dataTableId" rowIndexVar="rowIndex" rowKey="#{record.id}"
    rows="10" selection="#{bean.selectedRecord}" selectionMode="single"
    value="#{bean.allRecords}" var="record" widgetVar="dataTableWV">

    <p:ajax event="rowSelect"
        listener="#{bean.anotherMethod(record)}"
        update="somesIds" />

    <p:column>
        <p:selectOneMenu converter="omnifaces.SelectItemsConverter"
            id="selectOnMenuId" value="#{bean.recordDTO}">
            <f:selectItems
                itemLabel="#{status.name}" itemValue="#{status.id}" value="#{bean.statusList}" var="status" />
            <p:ajax event="change"
                listener="#{bean.anotherMethod(record)}"
                update="saveButtonId" />
        </p:selectOneMenu>
    </p:column>
    <p:column>
        <p:commandButton action="#{bean.someMethod}" icon="ui-icon-disk" id="saveButtonId" update="someId"/>
    </p:column>
</p:dataTable>

0 个答案:

没有答案