OnRowSelect of radobutton in Primefaces datatable

I have a datatable using JSF2.0 where I have strings displayed via radio

<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 Bean I have

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

However, the onRowSelect method onRowSelect not start. What could be the reason for this?

My idea of ​​a radio object is when a user clicks on a radio object, I would like to display the data under the main data with the details of the selected row.

Any help is 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}" /> 
+4
source share
2 answers

In Primefaces 3.4.2

no such attribute rowSelectListener

Use <p:ajax event="rowSelect" instead, as in a storefront

For radio / flag, etc. these are the available events <p:ajax

  • rowSelectRadio
  • rowSelectCheckbox
  • rowUnselectCheckbox
  • rowDblselect

See the showcase (find the p: ajax page on the page) DataTable - Select

+13
source

For an older version of Primefaces.

  <p:dataTable id="updateBanData" var="banSummary" value="#{sponsorBanMBean.sponsorBanForm.banSummaries}" styleClass="appTbl" selection="#{sponsorBanMBean.sponsorBanForm.selectedBanSummary}" emptyMessage="#{msgs.noRecordsFound}" selectionMode="single" > <p:ajax event="rowSelect" listener="#{sponsorBanMBean.onUpdateBanRowSelect}" update="updateSponsorShipBanDetailPanel"/> </p:p:dataTable> <p:outputPanel id="updateSponsorShipBanDetailPanel"> show your selection details. </p:outputPanel> 

Java code inside a Manged Bean.

  public void onUpdateBanRowSelect(SelectEvent selectEvent) { logger.logMethodStartAsDebug(); BanSummary selectedBanSummaryEvent = (BanSummary) selectEvent.getObject(); if(selectedBanSummaryEvent != null){ sponsorBanForm.setUpdateSponsorShipBanDetail(true); } logger.logMethodEndAsDebug(); } 
+1
source

All Articles