This discussion is archived
0 Replies Latest reply: Dec 27, 2012 6:19 PM by user20090209 RSS

Datatable selected row not available when user selects for first time

user20090209 Newbie
Currently Being Moderated

In my managed bean I have @ViewAccessScoped, I have noticed that when user selects a row from a datatable for the first time, the selected row is not available in managed bean, however for subsequent selections, selected row value is available in managed bean.

If I use session scope, then for the first time itself I am able to get the selected row value.

What could be the reason for this?
public class EmployeeManagedBean implements Serializable {

private Employee selectedRequest = new Employee();

   public void init() {

   private void initTable() {
      lazyModel = new LazyEmployeeDataModel(requestList, requestService);

   public LazyDataModel<Employee> getLazyModel() {
      return lazyModel;

and onRowSelect Method
public void onRowSelect(SelectEvent event) {
      try {
         setSelectedRequest((Employee) event.getObject());
         System.out.println("row "
               + getSelectedRequest()); 
JSF Code
<p:dataTable id="dataTable" var="req" lazy="true" value="#{emp.lazyModel}"
         paginator="true" rows="10"
      <p:ajax event="rowSelectRadio" listener="#{emp.onRowSelect}" /> 
       <p:column selectionMode="single" style="width:18px" />  


  • Correct Answers - 10 points
  • Helpful Answers - 5 points