This discussion is archived
4 Replies Latest reply: Nov 20, 2012 11:07 PM by Mohammad Jabr RSS

How to handle the current row with radio button selection???

925715 Explorer
Currently Being Moderated
Hi Everyone,

I have one ADF page with one table and one "Find" button.
I have created one new attribute with VARCHAR2(1) in the VO and dragged that attribute as first column in the table. And changed that first column to Radio Button to select only one row at a time.
Upon clicking on the "Find" button i need to get the values of current selected row.

How can i get the values of selected row?
What code should i write to get the values of selected row in Method Binding of "Find" button?

Any suggestions will be really useful.

Thanks.
  • 1. Re: How to handle the current row with radio button selection???
    AlejandroProfet Journeyer
    Currently Being Moderated
    Hi Kumar,

    You can store the selected radio value in a view scope variable using a af:setPropertyListener into the af:selectOneRadio, and autoSubmit="true":
    <af:selectBooleanRadio value="#{row.bindings.Checked.inputValue}" autoSubmit="true" id="sbr1">
      <af:setPropertyListener from="#{row.bindings.Checked.inputValue}" to="#{viewScope.currentRadio}" type="valueChange"/>
    </af:selectBooleanRadio>
    After that, you can access to current radio value through #{viewScope.currentRadio}

    AP

    Edited by: Alejandro Profet on Nov 20, 2012 4:37 PM

    Also you can get the value of selected radio binding the iterator field to a attributeValues in pageDef:
    <attributeValues IterBinding="YourVO1Iterator" id="Checked">
      <AttrNames>
        <Item Value="Checked"/>
      </AttrNames>
    </attributeValues>
    And reference it with this expression #{bindings.Checked.inputValue}.
  • 2. Re: How to handle the current row with radio button selection???
    934032 Newbie
    Currently Being Moderated
    Hi Kumar,

    http://adfwithejb.blogspot.in/2012/08/hi-i-came-across-one-common-use-case.html

    http://www.johnbrunswick.com/2011/08/adftable-get-selected-row-or-rows/

    http://tompeez.wordpress.com/2012/06/17/jdeveloper-fitler-table-on-transient-column/

    Thanks
    V T
  • 3. Re: How to handle the current row with radio button selection???
    925715 Explorer
    Currently Being Moderated
    Hi Profet and VT,

    thanks for ur response.
    VT, the links which u gave are for checkbox i need for radio button.can u plz provide that.

    Profet, After writing this code at source:

    <af:selectBooleanRadio value="#{row.bindings.Checked.inputValue}" autoSubmit="true" id="sbr1">
    <af:setPropertyListener from="#{row.bindings.Checked.inputValue}" to="#{viewScope.currentRadio}" type="valueChange"/>
    </af:selectBooleanRadio>


    How can i get all the values of current row in backing bean method(method binding of Find method)?
    can u plz provide me the code for that?

    For the button "Find" i provided Action property and the method has generated in the backing bean as below:

    public String Find() {
    // Add event code here...

    return null;
    }

    what code should i write in the above method to get all the values of the selected row?

    Thanks.
  • 4. Re: How to handle the current row with radio button selection???
    Mohammad Jabr Guru
    Currently Being Moderated
    Hello Kumar,
    I have some comments on your case.
    >
    I have created one new attribute with VARCHAR2(1) in the VO
    >
    1- You should create this attribute in the Entity object and then add it to the view object.
    2- Do you need that only one radio button is set at a time for all rows ? If yes then you need to handle the case when the user set more than one row and clear the value of the attribute for all other rows.

    >
    How can i get all the values of current row in backing bean method(method binding of Find method)?
    can u plz provide me the code for that?
    >
    If you mean by the current row is that the row with its value of the selected attribute is set (the radio button is set for that row), then you can write a method in the viewObjectImpl class and expose it to client interface and call it from your bean.
    here is an example based in Department table in HR schema.
    //This method is written in DepartmentsViewImpl    
    public Row getSelectedRadioRow(){
                //create a second row set to not impact the row set used in ADF
                RowSet duplicateRowSet = this.createRowSet("duplicateRowSet");
                //get the current row of the table to set it back after re-executing the VO
                DepartmentsViewRowImpl currentRow = (DepartmentsViewRowImpl)this.getCurrentRow(); 
                Row[] filteredRows = duplicateRowSet.getFilteredRows("IsSelected", "1");
                DepartmentsViewRowImpl row=null;
                if(filteredRows.length>0){
                    row = (DepartmentsViewRowImpl)filteredRows[0];
                    System.out.println("Department Name " + row.getDepartmentName());               
                     }
                this.setCurrentRow(currentRow); 
                duplicateRowSet.closeRowSet();
                return row;            
            }

Legend

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