I'm trying to implement a master-detail type scenario where a search is performed to populate a dataTable with a list of users, the user name can then be clicked to view the details.

The method I am attempting to use is described on the Myfaces Wiki -
3) Getting handle to DataModel Row
http://wiki.apache.org/myfaces/ExecutingMethodsFromLinkButtonParameters

When I have my managed bean set to session scope it all works fine, the only problem is that I don't want it in the session scope, once set to request scope the userDetails method does not get fired when I click on the commandLink, I simply get bumped back to the original view with a blank data table.

I have tried using <t:saveState..../> but I get an error as org.apache.myfaces.component.html.ext.HtmlDataTable is not serializable.

Relevant code:

  <managed-bean>
      <managed-bean-name>userAdmin</managed-bean-name>
<managed-bean-class>com.mydomain.view.bean.UserAdminBean</ managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
  </managed-bean>

users.xhtml
......
<t:dataTable
  value="#{userAdmin.foundUsers}" var="user"
  binding="#{userAdmin.userTable}"
  rendered="#{userAdmin.displayResults}"
  preserveDataModel="true">
  <h:column id="col1">
    <f:facet name="header">
      <h:outputText value="#{msgs['label.user.id']}" />
    </f:facet>
    <t:commandLink action="#{userAdmin.userDetails}"
      value="#{user.userId}" />
  </h:column>
</t:dataTable>


UserAdminBean.java
...
private UIData userTable;
...
public String userDetails()
       User appUser = (User) userTable.getRowData();
getApplication().createValueBinding("#{appUser}").setValue (getFacesContext(), appUser);
       return Constants.SUCCESS;
}

One thing particularly puzzling me is why the userDetails() method does not get fired at all when clicking the commandLink. Being new to JSF it's probably my lack of understanding of the lifecycle but I'd appreciate some pointers as to how other people have solved this problem without resorting to placing the dataTable in the session scope.

Regards
Gianni

Reply via email to