onRow在Primefaces数据表中选择单选按钮(onRowSelect of radiobutton in Primefaces datatable)

编程入门 行业动态 更新时间:2024-10-26 16:25:38
onRow在Primefaces数据表中选择单选按钮(onRowSelect of radiobutton in Primefaces datatable)

我有一个使用JSF2.0的数据表,其中我使用单选按钮显示行

<p:dataTable id="dataTable" var="emp" lazy="true" value="#{req.lazyModel}" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10" selection="#{req.selectedEmp}" rowKey="#{req.empNo}" rowSelectListener="#{req.onRowSelect}"> <p:column selectionMode="single" style="width:18px" />

在我拥有的豆子里

public void onRowSelect(SelectEvent event) { System.out.println("row "+((Request) event.getObject()).getEmpNo()); }

然而onRowSelect方法没有被调用。 这可能是什么原因?

我对单选按钮的想法是,当用户单击单选按钮时,我想在主数据表下面显示一个数据表,其中包含所选行的详细信息。

任何帮助,高度赞赏。

更新1

<p:dataTable id="dataTable" var="emp" lazy="true" value="#{req.lazyModel}" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10" selection="#{req.selectedEmp}"> <p:column selectionMode="single" style="width:18px" /> <p:ajax event="rowSelect" listener="#{reqMB.onRowSelect}" />

I have a datatable using JSF2.0 where I have rows displayed with radiobutton

<p:dataTable id="dataTable" var="emp" lazy="true" value="#{req.lazyModel}" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10" selection="#{req.selectedEmp}" rowKey="#{req.empNo}" rowSelectListener="#{req.onRowSelect}"> <p:column selectionMode="single" style="width:18px" />

and in Bean I have

public void onRowSelect(SelectEvent event) { System.out.println("row "+((Request) event.getObject()).getEmpNo()); }

However onRowSelect method is not getting invoked. What could be the reason for this?

My idea of radiobutton is when user clicks radiobutton, I would like to display a datatable below the master datatable with details of selected row.

Any help is highly appreciated.

Update 1

<p:dataTable id="dataTable" var="emp" lazy="true" value="#{req.lazyModel}" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10" selection="#{req.selectedEmp}"> <p:column selectionMode="single" style="width:18px" /> <p:ajax event="rowSelect" listener="#{reqMB.onRowSelect}" />

最满意答案

Primefaces 3.4.2中没有这样的属性rowSelectListener

改为使用<p:ajax event="rowSelect" ,就像在展示中一样

对于收音机/复选框等......这些是可用的<p:ajax事件

rowSelectRadio rowSelectCheckbox rowUnselectCheckbox rowDblselect

查看展示(在页面上搜索p:ajax) DataTable - 选择

There is no such attribute rowSelectListener in Primefaces 3.4.2

Use <p:ajax event="rowSelect" instead , like in the showcase

For radio/checkbox etc... these are the available <p:ajax event

rowSelectRadio rowSelectCheckbox rowUnselectCheckbox rowDblselect

See the showcase (search for p:ajax on the page) DataTable - Selection

更多推荐

本文发布于:2023-07-21 11:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1209762.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单选   数据表   按钮   Primefaces   onRow

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!