【发布时间】:2015-10-23 01:55:05
【问题描述】:
我在 PrimeFaces 中创建了一个数据表,它接收并呈现对象列表。在行的末尾,我有一个 commandButton 元素,当它被使用时,它会在服务器上的 managedBean 上做一些事情。
当前行的所有数据都是使用放置在 param 属性的命令按钮中的对象 ID 检索的。
问题是我有一个 selectOneMenu 元素,它与对象无关。我选择了一个影响背后逻辑的值。
这是表格:
<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">
...那个选择
<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>
我希望能够从触发操作的特定行中获取选择元素的值。
我尝试过使用context.findComponent(),但即使我将JSF 表生成的索引为form:table:index:staticIdOfSelect 的元素的绝对路径放入元素的绝对路径,它也会给我null。
我不知道如何获取兄弟元素。那是另一个。
来自 bean 类:
@ManagedBean
@SessionScoped
public class IndexBean
我真的被困在这里了。 提前致谢!
【问题讨论】:
标签: jsf-2 primefaces datatable