mercredi 22 mars 2017

valueChangeListener not invoked 2nd time when checkbox is checked/unchecked

I am using af:selectBooleanCheckbox in a jspx page. Here is code for it

 <af:iterator id="itr2"
                                     value="#{MainPageContainerListeners.successNames}"
                                     var="row" rows="0">
                          <af:panelGroupLayout id="pgl4"
                                               layout="horizontal">
                            <af:selectBooleanCheckbox text="#{row}"
                                                      id="Successors"
                                                      selected="true"
                                                      autoSubmit="true"
                                                      valueChangeListener="#{MainPageContainerListeners.SuccessorChangeEvent}"
                                                      binding="#{MainPageContainerListeners.successeeNames}"></af:selectBooleanCheckbox>
                          </af:panelGroupLayout>
                        </af:iterator>

There are 9 panelGroupLayout and some names are displayed in panelGroupLayout using outputText.

When user checks or unchecks one of the checkbox then respective name in one of the 9 panelGroupLayout should appear/disappear.

All the panelGroupLayout are included in panelDashboard, so I have set partialTriggers on panelDashboard. Here is code of panelDashboard

<af:panelDashboard id="pd1"
                                           columns="#{sessionScope.Dimension}"
                                           rowHeight="#{sessionScope.RowHeight}"
                                           partialTriggers="itr2:Successors">

In a java file I have written the code to set names in respective panelGroupLayout. There I have written valueChangeListener for selectBooleanCheckbox. Here is code for valueChangeListener

    public void SuccessorChangeEvent(ValueChangeEvent valueChangeEvent) {
    ArrayList SuccessName = new ArrayList();         
    System.out.println("e1 " + valueChangeEvent.getNewValue());
    valueChangeEvent.getOldValue();
    SuccessNames = new ArrayList();
    System.out.println("e2 " + valueChangeEvent.getOldValue());
    System.out.println("e3 " + valueChangeEvent.getNewValue());
    boolean isSelected =
        ((Boolean)valueChangeEvent.getNewValue()).booleanValue();
    System.out.println("e5 " + isSelected);

    Map attributeMap = valueChangeEvent.getComponent().getAttributes();
    String fullName = (String)attributeMap.get("text");
    System.out.println("SUCCESSOR CHANGE " + fullName);
    if (!isSelected) {
        SuccessName.add(fullName);
    }
    System.out.println(SuccessName);
    System.out.println("MAP" + attributeMap);
    MainPageContainerListener obj = new MainPageContainerListener();
    obj.displaySucceee(SuccessName);

}

displaySucceee manages the names to be displayed in panelGroupLayout.

Issue I am having is SuccessorChangeEvent is called only once when I check/uncheck checkbox 2nd time SuccessorChangeEvent is not called. Can someone please help me




Aucun commentaire:

Enregistrer un commentaire