1

I am using a rich extendedDataTable which will be populating a list of user names. Once the user selects the selected values will be bold. But my issue is, once the table is reset the previously selected values remain in bold. Any one knows how to resolve this issue?

View :

<rich:extendedDataTable value="#{reportBean.allActiveUsers}"
        var="user"
        selection="#{reportBean.selection}"
        selectionMode="multiple"
        style="height:175px; width:200px;"
        id="userist">
    <a4j:ajax execute="@this" event="selectionchange" listener="#{reportBean.userSelectionListener}" render="projectList"/>
    <rich:column width="160px">
        <h:outputText value="#{user.name}" />
        <h:inputHidden value="#{user.userId}"/>
    </rich:column>
</rich:extendedDataTable>

<a4j:commandButton id="clearBtn" value="Clear"  tabindex="4">
    <a4j:ajax event="click" execute="@this" listener="#{reportBean.reset}" render="resourceList"/>
 </a4j:commandButton>

Code :

// Loading
List<User> allActiveUsers = new ArrayList<User>();

// Reset
allActiveUsers = new ArrayList<User>();

public void reset(){
    setAllActiveUsers(getUserFacade().getAllUsers());
}
user1266343
  • 177
  • 5
  • 16

3 Answers3

0

Your button is a bit messy, you don't need a4j:ajax when using a4j:commandButton since this component is already AJAX.

<a4j:commandButton id="clearBtn" value="Clear"  tabindex="4">
    <a4j:ajax event="click" execute="@this" listener="#{reportBean.reset}" render="resourceList"/>
</a4j:commandButton>

for this :

<a4j:commandButton value="Clear" tabindex="4" execute="@this" listener="#{reportBean.reset()}" render="resourceList userist"/>

You were missing the right component to update, also I doubt your listener was called. In JSF 2.0 you can call listeners methods without parameters but when you do it so, you need to add () at the end. Ortherwise you should declare your method like this :

public void reset(AjaxBehaviorEvent event) {
    allActiveUsers = new ArrayList<User>();
}
Alexandre Lavoie
  • 8,711
  • 3
  • 31
  • 72
  • Thanks for the reply, i tried changing as u suggested but no luck :( – user1266343 Jun 10 '13 at 07:17
  • @user1266343 I'm a bit tired, I've updated the answer, also I suggest 2 things. 1. Verify in debug that your method `reset` is really called, 2. Add `` somewhere in your view and see if there are errors when you click the Clear button. – Alexandre Lavoie Jun 10 '13 at 07:20
0

Maybe too late to answer this. Same issue was bugging me. The fix is to clear the selection list in the listener/action of the a4j button and set the ActiveRow to null in the oncomplete event of the a4j button (tbodies is checked to handle empty table case.

oncomplete="(#{rich:component('tableID')}.tbodies)?#rich:component('tableID')}.setActiveRow(null):''"

Also set the selection property in the bean to null in the respective action.

Community
  • 1
  • 1
Rohan K
  • 21
  • 3
0

I just found out how to reset the current selection on client after an AJAX request, add an 'onready' listener to EDT:

onready="var edt = #{rich:component('yourExtendedDataTableId')}; edt.deselectRow(edt.activeIndex);"