从 PrimeFaces 数据表行获取兄弟元素

Get sibling element from PrimeFaces datatable row

我在 PrimeFaces 中创建了一个数据table,它接收并呈现对象列表。在该行的末尾,我有一个 commandButton 元素,当使用它时,它会在服务器上的 managedBean 上执行一些操作。

有关当前行的所有数据都是使用放置在 param 属性中的命令按钮中的对象 ID 检索的。

问题是我有一个 selectOneMenu 元素,它与对象无关。我select一个影响背后逻辑的值。

这里是 table:

<h:panelGrid id="panel" columns="2" bgcolor="#cce4ff"
                     cellpadding="10" cellspacing="1" rendered="#{indexBean.showChannelList}"
                     style="margin-top: 10px; margin-left: 100px;">
            <p:dataTable var="program" value="#{indexBean.programList}" style="width:1000px;"
                         paginator="True" rows="10" rowIndexVar="row" sortBy="#{program.id}"
                         paginatorPosition="bottom" widgetVar="programDT" id="programDT">

...即select

<p:column headerText="text" width="15%">
                    <h:selectOneMenu id="select-valability" value="#{indexBean.valabilitySelected}" disabled="#{indexBean.disabled}" style="font-size: small;">
                        <f:selectItems value="#{indexBean.listValabilities}" />
                        <f:param value="#{program.id}" />
                        <f:ajax resetValues="true" />
                    </h:selectOneMenu>
                </p:column>

...还有命令按钮

<p:column headerText="text" width="20%" style="text-align: center;">
                    <h:commandButton id="cmd-button-id" value="gen JSON" action="#{indexBean.action}" 
                                     style="width: 200px; height: 30px;"
                                     class="ui-button ui-widget ui-state-default ui-corner-all"
                                     >
                        <f:param name="programId" value="#{program.id}" />

                    </h:commandButton>
                </p:column>

我希望能够从触发操作的特定行中获取 select 元素的值。

我已经尝试使用 context.findComponent(),但即使我将 JSF table 生成的索引的元素的绝对路径作为 form:table:index:staticIdOfSelect,它也会给我 null。

我不知道如何获取兄弟元素。那是另一回事了。

来自豆子class:

@ManagedBean
@SessionScoped
public class IndexBean

我真的被困在这里了。 提前致谢!

使用行上的一些元素在 bean 中设置一个 ajax 侦听器来存储数据,然后更新="the element" 你想从中获取信息。