tags:

views:

310

answers:

1

Hi all,

I am developing a web app using JSF, RichFaces, EJB3, Hibernate and Seam.

I have an extended data table and showing a list (say userList) which has multi columns in it. Moreover, because of that this datatable is selectable, I want to keep the selected row indexes even if the sorting is changed by the user.

In other words of what I mean is that when the sorting of columns is changed, the order of row indexes is changed as well. Therefore, I want to invoke an action when the user clicks on sorting on each time. I tried many ways, but could nt find a solution to achieve it yet.

Do you have any idea about which listener or method is being called when sorting is clicked by the user in rich extendeddatatable? I cant understand what the point is in that...

Any help would be appreciated. Many Thanks, Baris

A: 

A code sample would have been nice, but it sounds like you have a separate list that contains the selected indices, and only update that list on a selection event.

Have you considered having the selection state live with the data object via a bean:

public DataBean {
  private DataModel model;
  private boolean selected;

  //standard getters and setters omitted
}

JSF code:

<h:column>
  <h:selectBooleanCheckbox value="dataBean.selected">
    <a4j:support event="onclick" ajaxsingle="true" />
  </h:selectBooleanCheckbox>
</h:column>

Tie your selection state to the model like this and sorting won't be an issue at all.

Naganalf
Many thanks for your reply at first. Even if your approach is a good one, it is not directly related about my problem indeed. I would just like to know how I can invoke an action when user clicks the little sorting arrow which is placed at the top of each columns individually. <rich:column sortable="true" sortBy="#{cap.userId}" filterBy="#{cap.userId}" filterEvent="onkeyup" width="170px" id="col1" label="User ID"> <f:facet name="header"> <h:outputText value="User ID" id="out1"/> </f:facet> <h:outputText value="#{cap.userId}" id="out2"/></rich:column>
Bariscan
The problem you stated was that you were losing the selection state of your rows after sorting...
Naganalf
The extended data table does not require using a selectbooleancheckbox in order to keep selection state. That's why I dont prefer to use a checkbox in my case it is waste while extended tabel enables user to select a row by just clicking the row itself.So the actual problem in here is, I am synchronizing extendedtable with my list got from backing bean. I can get the selected row key. But when sorting is changed, it is not match the row key with my result list.As a result, if i can execute an action when user clicks sorting arrow, everything will be ok.How can i execute an action as sorting?
Bariscan