This discussion is archived
5 Replies Latest reply: Sep 10, 2013 3:00 AM by BalaMaheshwaran RSS

Checkbox integration with Tree always returning the first row

BalaMaheshwaran Newbie
Currently Being Moderated

Hi All,

                    I'm new to ADF and at present designing a employee hierarchy page. I have a single VO which has employee_id and supervisor_id and other details regarding an employee. I have a ViewLink to link empid and SupervisorId.

I have created a tree using the VO and it works fine. Now i have added selectbooleancheckbox to select/deselect an employee or employees. When ever a user deselects a checkbox i need to change an attribute in VO related to that particular employee record to false.

But my problem is i'm not able to catch the row in which the user selected or deselected the checkbox. I have a valueChangeListener and i have added the following sample code to catch hold of the row.

 

    public void CheckBoxValueChange(ValueChangeEvent valueChangeEvent) {

      

        valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());

      

        //BindingContext bctx = BindingContext.getCurrent();

        // BindingContainer bindings = bctx.getCurrentBindingsEntry();

  

      

        System.out.println("Start checkBoxChange ");

        System.out.println("OLD VALUE:"+valueChangeEvent.getOldValue());

        System.out.println("NEW VALUE:"+valueChangeEvent.getNewValue());

 

 

 

 

        DCIteratorBinding dcIb = AdfUtils.findIterator("Rating1Iterator");

        RatingRowImpl parent = (RatingRowImpl)dcIb.getCurrentRow();

        System.out.println(parent.getFullName());

        RowIterator ri = parent.getPersonIdRating();

 

}

 

But it always returns the first row on of the VO and not the currently selected one. I have checked other forums and tried attribute binding and other methods too but nothing is helping me to overcome this issue.

 

Following is m

  • 1. Re: Checkbox integration with Tree always returning the first row
    Cvele_new_account Expert
    Currently Being Moderated

    In your VO, make one new transient Boolean attribute, let say BooleanAttr. And make him as Always updateable

    Then, in the ViewRowImpl class, modify setter and getter for BooleanAttr to be as follows:

     

    public void setBooleanAttr(Boolean value) {
        if (value != null &&  value){
                    setRealAttr(_some_real_value);
        }else{
                    setRealAttr(_some_other_value);
        }
    }

     

    public Boolean getBooleanAttr() {
           // return true or false, regarading the RealAttr
    }

    In that way, you can manage the real attribute with your transient one.

    You can use that new atribute in the af:tree, you can represent him as af:selectBooleanCheckbox.

  • 2. Re: Checkbox integration with Tree always returning the first row
    BalaMaheshwaran Newbie
    Currently Being Moderated

    Hi,

               Yes you are right. But my problem is i'm getting hold of the row where the person has selected/deselected the checkbox in ValueChangeListener.

     

           DCIteratorBinding dcIb = AdfUtils.findIterator("Rating1Iterator");

            RatingRowImpl parent = (RatingRowImpl)dcIb.getCurrentRow();

     

    The code above is not returning the current row where the user selected/deselected. It always returns me the first row of the Tree not the selected one.

  • 3. Re: Checkbox integration with Tree always returning the first row
    Cvele_new_account Expert
    Currently Being Moderated

    take a look at setBooleanAttr() I provided you.

    When user select/deselect checkBox (with autosubmit=true), setBooleanAttr() are called, so you are _just in the row you are looking for...

  • 4. Re: Checkbox integration with Tree always returning the first row
    Cvele_new_account Expert
    Currently Being Moderated

    Also, if you want to know af:tree selected row in the ViewController (backing bean), take a look at:

     

    access the selected child node(not the root node) in adf tree

  • 5. Re: Checkbox integration with Tree always returning the first row
    BalaMaheshwaran Newbie
    Currently Being Moderated

    Hi,

                 This is my Checkbox and Tree structure

     

    <f:facet name="first">

                        <af:tree value="#{bindings.Rating13.treeModel}" var="node"

                                 selectionListener="#{bindings.Rating13.treeModel.makeCurrent}" rowSelection="multiple"

                                 id="t1" displayRow="selected" partialTriggers="sbc1">

                            <f:facet name="nodeStamp">

                                <af:group id="g1">

                                    <af:selectBooleanCheckbox label="Label 1" id="sbc1"

                                                              value="#{node.SelectedCheck}"

                                                              valueChangeListener="#{TreeListeners.CheckBoxValueChange}"

                                                              autoSubmit="true"

                                                              binding="#{TreeListeners.bindingListenerCheckBox}"

                                                              immediate="true"/>

                                    <af:outputText value="#{node.FullName}" id="ot1"/>

                                </af:group>

                            </f:facet>

     

    Im able to get access to current row in VORowImpl after making auto submit to true. My requirement is to unselect all the checkboxes of reportees when manager checkbox is disabled.  As you said should i iterate over all the items in Backing bean or is there any other way to get currently changed row in backing bean some thing like

        DCIteratorBinding dcIb = AdfUtils.findIterator("Rating1Iterator");

            RatingRowImpl parent = (RatingRowImpl)dcIb.getCurrentRow();

Legend

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