在JSF2中双击Richfaces extendedDataTable时,获取所选项目 [英] Get selected item when double clicking on a Richfaces extendedDataTable in JSF2
问题描述
< rich:extendedDataTable
value =#{bean.loadedAnfragen }var =anfrage
selection =#{bean.selectedAnfrage}id =anfragenTable
selectionMode =single
onrowdblclick =showAnfrage();>
...这里是我的列...
< / rich:extendedDataTable>
< a4j:jsFunction name =showAnfrageaction =#{bean.showAnfrage}/>
bean中的方法被调用,但选择(双击的行)为null。这是适当方法的代码:
public void showAnfrage(){
UIExtendedDataTable table = (UIExtendedDataTable)FacesContext.getCurrentInstance()。getViewRoot()。findComponent(mainForm:anfragenTable);
if(table!= null){
for(Object selection:table.getSelection()){
System.out.println(Thats the selected object:+选择);
}
}
}
我还尝试了一些ajax的东西。我想通过 f:setPropertyActionListener
在 a4j:ajax
标签中传递选项,但这是不可能的,因为datatable本身是没有动作源,所以setPropertyActionListener标签不能被调用。
Doeas任何人都有一个解决方案来获取选择的项目,在双引号的extendedDataTable行?
我已经实现了onrowclick:
< a4j:jsFunction name =selectRowaction =#{chAction.selectClient}>
< a4j:param name =selectedClientIdassignTo =#{chAction.selectedClientId}/>
< / a4j:jsFunction>
< rich:dataTable id =chTable
rows =#{referenceData.recordsPerPage}style =width:100%
value =#{chAction .clients}var =ressortMode =single
rowClasses =oddrow,evenrow
onrowclick =selectRow('#{res.clientId}')
rowKeyVar = currRow>
您可以将事件更改为双点击。
In my JSF 2 application I have a Richfaces extendedDataTable. When I doubleclick on a row I want to leave this page and I will display the details of the selected table entry on this other page. I tryied the following in the table page:
<rich:extendedDataTable
value="#{bean.loadedAnfragen}" var="anfrage"
selection="#{bean.selectedAnfrage}" id="anfragenTable"
selectionMode="single"
onrowdblclick="showAnfrage();">
... here are my columns ...
</rich:extendedDataTable>
<a4j:jsFunction name="showAnfrage" action="#{bean.showAnfrage}" />
The method in the bean gets called but the selection (the row where I double clicked) is null. This is the code for the appropriate method:
public void showAnfrage() {
UIExtendedDataTable table = ( UIExtendedDataTable )FacesContext.getCurrentInstance().getViewRoot().findComponent( "mainForm:anfragenTable" );
if( table != null ) {
for( Object selection : table.getSelection() ) {
System.out.println( "Thats the selected object: " + selection );
}
}
}
I also tried some ajax stuff. I wanted to pass the selection with f:setPropertyActionListener
inside an a4j:ajax
tag but this is impossible because the datatable itself is no action source so the setPropertyActionListener tag cannot be called.
Doeas anyone has a solution for getting the selected item after doubliclicking the extendedDataTable row?
I have implemented it with onrowclick:
<a4j:jsFunction name="selectRow" action="#{chAction.selectClient}">
<a4j:param name="selectedClientId" assignTo="#{chAction.selectedClientId}" />
</a4j:jsFunction>
<rich:dataTable id="chTable"
rows="#{referenceData.recordsPerPage}" style="width: 100%"
value="#{chAction.clients}" var="res" sortMode="single"
rowClasses="oddrow, evenrow"
onrowclick="selectRow('#{res.clientId}')"
rowKeyVar="currRow" >
You can change event to double click.
这篇关于在JSF2中双击Richfaces extendedDataTable时,获取所选项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!