Row selection across multiple tables

Hi
I currently have multiple tables where, if the user selects a particular row or group of rows in one table the correspondign row or group of rows is selected in the other table.
At the moment I've acheived this by placing listSelection listeners on all the tables so that when the selection on one table changes it fires an event and updates the slection on the other tables using:
secondTable.setRowSelectionInterval(
firstTable.getSelectedRows()[0],
firstTable.getSelectedRows()[firstTable.getSelectedRowCount() - 1]
);This works fine if the user selects a single row or a continuous group of rows. THe problem is if the user selected a non-continuous group, or selects a continuous group and then deselects some of these rows.
Because the method I've got selects all rows between the start and finish of the selection it means rows are highlighted on the other tables that are not highlighted on the first table.
My thoughts on how to approach this would be to cycle through the array of selected rows and select the corresponding rows in the other tables individually rather than selecting a range, but I can't see how to accomplish this. Could anyone give me some pointers or suggestions.
Thanks

What you are doing is correct in principle (use a
listener to propagate the selection)
Always a good start :-)
but you need to
understand the subtleties of the ListSelectionEvent -
read the API carefully - it gives you a range of
indices which may have changed but does not tell you
whether any specific indices in that range are
selected or unselected.
That makes sense, the event just indicates that the selection has changed yes?
For that you will need to get
the source ListModel from the event and query each
row in the event range to determine its selection
state.
This is where I run into difficulty. I think I can go through the each row and find out if its selected or not (using isSelectedIndex(i))
What I'm unsure what to do is how to set that for the rows in the other ListModels. What I would have normally done would be something like
otherListModel.getIndex(i).setSelected(firstListModel.isSelectedIndex(i));But as the api doesnt list the methods to do that I think I might not have got this concept sorted in my head. Could someone provide me with some pointers?
Thanks

Similar Messages

  • Using radio button selection in multiple tables

    Hello All,
    I've got a bit of a design issue and it being a Friday my brain is a bit foggy and I can't seem to figure out a solution.
    what I want to do is have 3 tables. The user should only be able to select one line from any of the three tables.
    I can do this by having events that clear down selection on the two other tables on any selection of the third, but the select buttons of tables don't really give the UI impression that only one row can be selected. To do this I'd like to use the radio button element.
    so
    table A
    choice - name
    (o) - Anne
    (o) - Bob
    (o) - Charlie
    Table B
    choice - name
    (x) - David
    (o) - Ellen
    (o) - Fran
    Table C
    choice - name
    (o) - George
    Here the entry in table B for David is selected. But any selection of any of the other options should deselected.
    My thoughts are to use a radio button ui element, bind the "selected" value to a unique id for each row/table (an attribute of the node element for each table) and the value to a common shared attribute (not table specific).
    Any better ideas - and certainly any which would mean I'm not going to have to maintain a lookup table of my unique ids and node elements to find out which one is selected?
    Cheers,
    Chris

    Ok - here's how I did it.
    I created another lookup table which had a guid and reference to the element.
    in the each elements I had a guid which I bound to the key for selection property of the radio button in the table.
    I then bound the selected key property to an attribute that was common to all elements.
    in my "processing" logic I read the selected key, read the lookup table - and therefore got the reference to the selected element.
    Would have been an awful lot easier if I could have used a reference to the element itself as the "key" - but that was required to be a character field.
    [image showing radio button selection working across multiple tables|http://i51.tinypic.com/bi79dx.jpg]
    End result works quite nicely.
    Cheers,
    Chris

  • Reg Row Selection in a Table

    Hi All,
    I am facing a problem with row selection in a table. When I navigate from one screen to another in my application, the selected rows in the previous screen should be populated in the table in the next screen.
    If I have to use checkboxes inside the table for multiple row selection, how could I populate the table in the next screen with all the selected rows of the table from the previous screen.
    Also, is it possible to select multiple rows in a table without using checkboxes, and by selecting the "selection mode" of table as "multi", so that initially when the page is loaded no record (row) should be selected automatically.
    Please help me regarding this.
    Regards,
    Murthy.

    Hi,
    As Armin suggested you can use the inbuilt multiselection property of the table.
    For populating the selected values in a table in second view
    First view Context structure
    -EmpDetails (Table node) (cardinality 0..n,selection 0..n,intializeleadSelection - false)
    ---EmpID (table column)
    ---Name  (table column)
    Second View Context structure
    -DispalySelected (Table node)-EmpDetails (Table node) (cardinality 0..n,intializeleadSelection - false)
    --- ID(table column)
    --- Name(table column)
    create a navigation link form first view to second view
    In the InBoundPlug of second view
        wdContext.nodeDisplaySelected().invalidate();
        for(int i=0;i<wdContext.nodeEmpDetails().size();i++)
             if(wdContext.nodeEmpDetails().isMultiSelected(i))
                   IPrivateDisplayView.IDisplaySelectedElement ele = wdContext.nodeDisplaySelected().createDisplaySelectedElement();
                   wdContext.nodeDisplaySelected().addElement(ele);
                   ele.setID(wdContext.nodeEmpDetails().getEmpDetailsElementAt(i).getEmpID());
                   ele.setName(wdContext.nodeEmpDetails().getEmpDetailsElementAt(i).getName());
    <b>For multiselecting you have to use Ctrl tab</b>

  • How to dynamically display the data from a table base on row selection of another table in ADF

    Hi ,
    I have a requirement in ADF. I need to change the data of a table  based on row selection of another Table . Both the table have a Parent Child relationship between them. They have a common attribute say department_id.
                                                                                         For this I created bind variable in view object of employees table and wrote a where clause in the sql query using that bind variable. Then I created method for selection listener of department Table in java bean.
    My method is following
        public void onrowselection(SelectionEvent selectionEvent) {
            RichTable richTable = (RichTable)selectionEvent.getSource();
                            CollectionModel tableModel = (CollectionModel)richTable.getValue();
                            JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
                            Object selectedRowData = richTable.getSelectedRowData();
                            JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
                    oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
                    Number pallet = newVal.bigDecimalValue();
                    System.out.println("Selected values " + pallet);
            BindingContext bindingctx = BindingContext.getCurrent();
                          BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
                          DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
                  DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
                          ViewObject vo =dciter.getViewObject();
                          vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
                          vo.executeQuery();
    It is printing the selected value of department id from department table in the log. But it is not able to pass the value to employees view. It is showing the following error in the log
    "Definition DepartmentId of type Variable is not found in EmployeesView1."
    I will be very thankful if someone helps me to solve this errror or is there any other way to achieve the same requirement.
    Thanks
    Nilesh

    Note quite sure why you simply wont create a viewlink for the viewobject the tables are based on..
    The viewlink attribute will be based on the departmentId and it's a simple master detail relationship which automatically uses ppr.
    However, if both tables are on the same page; using your hack about;
    On the underlying viewobject, define a viewcriteria e.g. "listById" and set your bind variable here.
    I would bind table two to a RichTable component:
    RichTable t2;
    public void onrowselection(SelectionEvent selectionEvent) {
            RichTable richTable = (RichTable)selectionEvent.getSource();
                            CollectionModel tableModel = (CollectionModel)richTable.getValue();
                            JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
                            Object selectedRowData = richTable.getSelectedRowData();
                            JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
                    oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
                    Number pallet = newVal.bigDecimalValue();
                    System.out.println("Selected values " + pallet);
                   refreshTable2(pallet);
            BindingContext bindingctx = BindingContext.getCurrent();
                          BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
                          DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
                  DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
                          ViewObject vo =dciter.getViewObject();
                          vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
                          vo.executeQuery();
    private void refreshTable2(Number pallet){
    RichTable x=getT2();
    CollectionModel cm=(CollectionModel)x.getValue();
    JUCtrlHierBinding jcb=(JUCtrlHierBinding)cm.getWrappedData();
    BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
    DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
    DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(jcb.getName()+"Iterator");
    ViewObject vo =dciter.getViewObject();
    ViewCriteriaManager vcm=vo.getViewCriteriaManager();
    ViewCriteria vc=vcm.getViewCriteria("listById");
    vo.applyViewCriteria(vc);
    vo.setNamedWhereClauseParam("DepartmentId",pallet);
    vo.executeQuery();
    AdfFacesContext.getCurrentInstance().addPartialTarget(getT2());

  • How to populate a table based on a row selection from another table.

    Hi, i just started to use ADF BC and Faces. Could some one help me or point me a solution on the following scenario .
    By using a search component , a table is being displayed as a search result. If i select any row in the resulted table , i need to populate an another table at the bottom of the same page from another view. These two tables are related by primary key . May i know how to populate a table based on a row selection from another table. Thanks
    ganesh

    I understand your requirement and the tutorial doesn't talk about Association between the views so that you can create a Master-Detail or in DB parlance, a Parent-Child relationship.
    I will assume that we are dealing with two entities here: Department and Employees where a particular Department has many Employees and hence a Parent-Child relationship.
    Firstly, you need to create an Association between the two Entities - Department and Employees. You can do that by right clicking on the model's entity and then associating the two entities with the appropriate key say, DepartmentId.
    Once you have done that, you need to link the two entities in the View section with this Association that you created. Then go to AppModule and make sure that in the Available View Objects: 'EmployeesView' appears under 'DepartmentView' as "EmployeesView via <link you created>". Shuttle the 'DepartmentView' to the right, Data Model and then shuttle
    "EmployeesView via <link you created>" to the right, Data Model under 'DepartmentView'.
    This will then be reflected in your Data Controls. After that, you simply would have to drag this View into your page as a Master-Detail form...and then when you run this page, any row selected in the Master table, would display the data in the Detail table.
    Also, refer to this link: [Master-Detail|http://baigsorcl.blogspot.com/2010/03/creating-master-detail-form-in-adf.html]
    Hope this helps.

  • How to disable first row selection in a table

    Hi,
    I have three tables which have master child relationship. I need to enable a button for each table based on row selection of corresponding table.But first row is being selected automatically and the buttons are enabled.
    what should i do in order to avoid first row selection in a table.I tried by removing selected Row Keys.But still i am getting the same problem.can anyone suggest on this.
    Thank You,
    Sukumar

    I know a hack but I don't recommend it, anyway here it goes:
    Remove selected Row Keys
    Change selectionListener from the default and create a custom action listener (You can call the default one inside of it) (Tip: use makeCurrent function in this PDF
    This will make sure that there is no selected row highlighted for the first time, but it actually means that the first row is selected, it's just not shown.
    This method is tested with 11.1.1.7

  • Selecting from multiple tables, into one internal table

    Hi,
    What is the best & most efficient method of selecting from multiple table (in my case 6,) into one internal table?
    Thanks,
    John
    Points will be rewarded and all responses will be highly appreciated.

    I have simple example :
    First one - Join 5 tables
    data : f1 type i,
              f2 type i,
              f3 type i.
    start-of-selection.
    get run time field f1.
    write the query 4 or 5 tables join.
    get run time field f2.
    f3 = f2 - f1 ( Total time).
    Second one - joins 3 table and use for all entries
    data : f1 type i,
              f2 type i,
              f3 type i.
    start-of-selection.
    get run time field f1.
    write the query 3 tables join and use for all entries
    get run time field f2.
    f3 = f2 - f1. ( Total time )
    Finally you can have time diffrence between the both sql statement.

  • Modifying datatype of columns across multiple tables

    Hi,
    I have a requirement where-in I have to modify the datatypes of columns across multiple tables. Is there any direct way to do this? I mean does oracle has any function or in-built functionality to achieve this.
    Example;
    Table1 -> col1 datatype needs to be changed to varchar2(10)
    Table2 -> col2 datatype needs to be changed to varchar2(30)
    Table3 -> col3 datatype needs to be changed to number.
    and so on....
    Do we have such functionality?
    Thanks,
    Ishan

    Hi Aman,
    Seeing the replies, I think I was unclear in the requirements. But I guess you understood it fully, but still I would like to restate my question once again, just to be 100% sure.
    What I actually want is that in one shot, I would be able to modify columns of multible tables.
    eg, table1-> col1 changed to varchar2(20);
    table2->col2 changed to varchar2(10)
    table3-> col3 changed to number;
    I know how to do it individually, but just wanted to check, if only one command can modify the datatypes of multiple tables/.
    If not, I have already written half the script, but just for knowledge sake wanted to check if some feature is available in oracle for that.
    Regards,
    Ishan

  • Single result set across multiple tables

    Hi - what's the best way to perform a single query that can pull
    a single result set across multiple tables, ie., a master table
    containing subject details and child table containing multiple
    records with detail.
    I know how to do this for two columns in the same table via
    indexing, but how about across tables?
    Cheers,
    John

    I am not sure if I understood your question, but you can use
    Intermedia Text with USER_DATA_STORE to create an index with data
    source from multiple tables.
    (see technet.oracle.com -> products -> oracle text)
    Thomas

  • Reg Row Selection in a Table UI Element

    Hi All,
    Can anyone help me in writing code to select a row from a table.
    I need to read the data from a row selected in a table and print it in the next page of my application.
    I request anyone to send me some coding line on how to select a row from a table and read data from it.
    Regards,
    Murthy.

    Hi Narayana,
    Follow the steps.
    Step1: Create a WD Component.
    Step2:  Under Component Controller create a
    i)  2  Node “EmployeeInfo” and “EmployeeRecord”  with attribute “EmployeeName” and “Position”  of cardinality 0..n for both the node and a context attribute “WindowInstance” of type “com.sap.tc.webdynpro.services.session.api.IWDWindow”
    Step3: Go to the Diagram View. Do the mapping between “EmployeeView” and “Component Controller” and between “DisplayView” and “Component Controller”
    Step4: Design 2 Views layout
    i>EmployeeView
    Layout like
    Employee Name |                                  Employee Position
    EmployeeInfo.EmployeeName| EmployeeInfo.Position
    EmployeeInfo.EmployeeName| EmployeeInfo.Position
    DisplayResultButton
    ii>DisplayView
    Layout like
    Employee Name   |                      Employee Position
    EmployeeRecord.EmployeeName |    EmployeeRecord.Position
    EmployeeRecord.EmployeeName |    EmployeeRecord.Position
    CloseWindowButton
    Step5: Create 2 Windows
    1>EmployeeWindow
    2>DisplayWindow.
    Under “EmployeeWindow” add the “EmployeeView”
    and “DisplayWindow” add the “DisplayView”
    Step5: Associate action “DisplayResult” with the “DisplayResultButton” and use this code inside the Implementation of “EmployeeView”
    public void wdDoInit()
        //@@begin wdDoInit()
    //initialize nodes
    wdContext.nodeEmployeeInfo().addElement(wdContext.createEmployeeInfoElement());
    wdContext.nodeEmployeeRecord ().addElement(wdContext.createEmployeeRecordElement());
        //@@end
    public void onActionDisplayResult(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionDisplayResult(ServerEvent)
    try
    IPrivateDisplayView.IEmployeeRecordElement empRec =
    wdContext.createEmployeeRecordElement();
    int n = wdContext.nodeEmployeeInfo().size();
    int leadSelected = wdContext.nodeEmployeeInfo().getLeadSelection();
    // loop backwards to avoid index troubles     
    for (int i = 0; i < n ; i++) {
    if (wdContext.nodeEmployeeInfo().isMultiSelected(i) || leadSelected == i) {
    empRec.setEmployeeName(wdContext.nodeEmployeeInfo().getElementAt(i).getAttributeValue("EmployeeName"));
    empRec.setPosition(wdContext.nodeEmployeeInfo().getElementAt(i).getAttributeValue("Position"));
    wdContext.nodeEmployeeRecord().addElement(empRec);
    catch(Exception e)
    e.printStackTrace();
    IWDWindowInfo windowInfo =(IWDWindowInfo) wdComponentAPI.getComponentInfo().findInWindows(
         "DisplayWindow");
    //        create the Window
         IWDWindow window = wdComponentAPI.getWindowManager().createWindow(windowInfo, true);
         window.setWindowPosition(WDWindowPos.CENTER);
         window.setTitle("WindowTitle");
         window.setWindowSize(200,200);
    //        Save WindowInstance in Context
         wdContext.currentContextElement().setWindowInstance(window);
    //        and show the window
         window.show();
         //wdThis.wdFirePlugInDisplay();
        //@@end
    Step6: Associate action “CloseWindow” with the “CloseWindowButton
    ” and use this code inside implementation of  “DisplayView”
      public void onActionCloseWindow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionCloseWindow(ServerEvent)
       IWDWindow window = wdContext.currentContextElement().getWindowInstance();
       window.destroyInstance();
        //@@end
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5f699f90-0201-0010-14a4-8950177281ed">Developing with Tables in WebDynpro</a>
    Regards,
    Mithu

  • How do I total across multiple Tables? Help!

    how do I total across multiple Tables? Help!
    I feel like a complete noob.

    Hi Marc,
    There is no function explicitly for that sort of array calculation in Numbers.
    My favorite way is to use a list of Table Names and the INDIRECT(ADDRESS) function combination to produce a SUM across tables. I'm making the assumption that you want to do something like adding up all the values in a particular cell of multiple tables.  For example "give me the total of all the A1 cells in tables T1, T2, T3 and T4".  For this I would use the formula:
    =INDIRECT(ADDRESS(1,1,1,,A))
    to grab the cell contents of the table names mentioned in column A of a summary table.  Once you have them collected in your summary table, add them up.
    Here's a screen shot...
    Hope that gives you an idea for approaching this problem.
    Jerry

  • Keep view in row selected in the table

    Hello,
    i have a webdynpro view with a table. This table has 256 records, and visibleRowCount property is set to 10 records.
    My problem is when i selected the record number 174 for example, the scroll table returns to position 1 and i can not see the record selected.
    How can i do for the scroll table keep the row selected in the table?
    Thank you

    Hi,
    Try this.
    1. create one context ctx_va_firstvisblerow.
    2.get the leadselection record and set ctx_va_firstvisblerow context.write this code in wdDoModifyView.and also following code in wdDoModifyView.
    IWDTable table = (IWDTable) view.getElement("Ur table id");
        table.setFirstVisibleRow(wdContext.currentContextElement().getCtx_va_visiblerow());
    3.Bind the ctx_va_firstvisblerow context to the table FirstVisibleRow.
    Thanks
    Abhilasha
    Edited by: Abhilasha Dahare on Sep 14, 2010 3:35 PM

  • Inserting records across multiple tables

    I'm still pretty new to working with databases, but have been
    fine using DW to use forms to add, edit and delete records from a
    flat table.
    I'm less sure about updating records across multiple tables,
    for example in a one to many rleationship with a look up table, eg
    If I have three tables
    Companies :
    CompanyID (INT, auto increment)
    Company
    Address
    etc
    Contacts :
    ContactID (INT, auto increment)
    FirstName
    LastName
    etc
    CompanyContacts :
    CompanyID (INT)
    ContactID (INT)
    It's straightforward enough to create pages to insert new
    records into the Companies or Contacts tables, but how do I go
    about populating the CompanyContacts table when I add a new record
    in the Contacts table, so that it becomes 'attached' to a
    particular 'Company'?
    If that makes sense.
    Iain

    I'm still pretty new to working with databases, but have been
    fine using DW to use forms to add, edit and delete records from a
    flat table.
    I'm less sure about updating records across multiple tables,
    for example in a one to many rleationship with a look up table, eg
    If I have three tables
    Companies :
    CompanyID (INT, auto increment)
    Company
    Address
    etc
    Contacts :
    ContactID (INT, auto increment)
    FirstName
    LastName
    etc
    CompanyContacts :
    CompanyID (INT)
    ContactID (INT)
    It's straightforward enough to create pages to insert new
    records into the Companies or Contacts tables, but how do I go
    about populating the CompanyContacts table when I add a new record
    in the Contacts table, so that it becomes 'attached' to a
    particular 'Company'?
    If that makes sense.
    Iain

  • Selecting rows across multiple tables (SSCCE provided)

    Greetings,
    I have a program that has 3 tables. When the user selects a row on one table, I want the corresponding rows in the other tables to be selected also. A corresponding row is defined (in this case) as a row whose column 1 value is the same. Column 1, in this case, is a company name, and the tables reference yearly info for those companies. So, if a user selects company #34, I would like it to select company #34 across the other two tables, also.
    I have established list selection listeners for each table that changes the selection for the other two tables.
    This code, however, doesn't work. two things are broken: 1) the cross-selection only works if the selection is moving up the table, but not down the table. 2) the scrrollRectToVisible on the viewport isn't working. What am I doing wrong? Thanks in advance.
    import java.awt.Rectangle;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import javax.swing.table.DefaultTableModel;
    * @author Ryan
    public class TableSelection {
        public static void main(String[] args){
            // Init data model data.
            Object[][] data = new Object[100][5];
            for(int i = 0; i < data.length; i++){
                data[0] = "Company # " + i;
    for(int j = 1; j < data[i].length; j++){
    data[i][j] = "" + i + ", " + j;
    // Init headers.
    String[] headers = {"Col 1" , "Col 2", "Col 3", "Col 4", "Col 5"};
    // All 3 data models are the same here, in my app however, they aren't.
    DefaultTableModel model1 = new DefaultTableModel(data, headers);
    DefaultTableModel model2 = new DefaultTableModel(data, headers);
    DefaultTableModel model3 = new DefaultTableModel(data, headers);
    // Init Tables. Tables and ScrollPanes are delcared as final to enable access from within ListSelectionEvent
    // Table 1
    final JTable jTable1 = new JTable(model1);
    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp1 = new JScrollPane();
    sp1.setViewportView(jTable1);
    // Table 2
    final JTable jTable2 = new JTable(model2);
    jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp2 = new JScrollPane();
    sp2.setViewportView(jTable2);
    // Table 3
    final JTable jTable3 = new JTable(model3);
    jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp3 = new JScrollPane();
    sp3.setViewportView(jTable3);
    // Add scrollpanes to panel.
    JPanel panel1 = new JPanel();
    panel1.add(sp1);
    panel1.add(sp2);
    panel1.add(sp3);
    // Add Panel to frame.
    JFrame frame = new JFrame("tableSelection");
    frame.add(panel1);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    // List Selection Listeners
    jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable1.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable2.getRowCount(); i++){
    if(jTable2.getValueAt(i, 0).equals(rowKey)){
    jTable2.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable2.getCellRect(i, 0, true);
    sp2.getViewport().scrollRectToVisible(rect);
    break;
    for(int i = 0; i < jTable3.getRowCount(); i++){
    if(jTable3.getValueAt(i, 0).equals(rowKey)){
    jTable3.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable3.getCellRect(i, 0, true);
    sp3.getViewport().scrollRectToVisible(rect);
    break;
    jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable2.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable1.getRowCount(); i++){
    if(jTable1.getValueAt(i, 0).equals(rowKey)){
    jTable1.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable1.getCellRect(i, 0, true);
    sp1.getViewport().scrollRectToVisible(rect);
    break;
    for(int i = 0; i < jTable3.getRowCount(); i++){
    if(jTable3.getValueAt(i, 0).equals(rowKey)){
    jTable3.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable3.getCellRect(i, 0, true);
    sp3.getViewport().scrollRectToVisible(rect);
    break;
    jTable3.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable3.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable1.getRowCount(); i++){
    if(jTable1.getValueAt(i, 0).equals(rowKey)){
    jTable1.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable1.getCellRect(i, 0, true);
    sp1.getViewport().scrollRectToVisible(rect);
    break;
    for(int i = 0; i < jTable2.getRowCount(); i++){
    if(jTable2.getValueAt(i, 0).equals(rowKey)){
    jTable2.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable2.getCellRect(i, 0, true);
    sp2.getViewport().scrollRectToVisible(rect);
    break;

    New code:
    import java.awt.Rectangle;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import javax.swing.table.DefaultTableModel;
    * @author Ryan
    public class TableSelection {
        public static void main(String[] args){
            // Init data model data.
            Object[][] data1 = new Object[100][5];
            Object[][] data2 = new Object[50][5];
            Object[][] data3 = new Object[50][5];
            for(int i = 0; i < data1.length; i++){
                data1[0] = "Company # " + (i+1);
    for(int j = 1; j < data1[i].length; j++){
    data1[i][j] = "" + (i+1) + ", " + j;
    for(int i = 0; i < data2.length; i++){
    data2[i][0] = "Company # " + ((i * 2) + 1);
    for(int j = 1; j < data2[i].length; j++){
    data2[i][j] = "" + ((i * 2) + 1) + ", " + j;
    for(int i = 0; i < data3.length; i++){
    data3[i][0] = "Company # " + (i * 2);
    for(int j = 1; j < data3[i].length; j++){
    data3[i][j] = "" + (i * 2) + ", " + j;
    // Init headers.
    String[] headers = {"Col 1" , "Col 2", "Col 3", "Col 4", "Col 5"};
    // All 3 data models are the same here, in my app however, they aren't.
    DefaultTableModel model1 = new DefaultTableModel(data1, headers);
    DefaultTableModel model2 = new DefaultTableModel(data2, headers);
    DefaultTableModel model3 = new DefaultTableModel(data3, headers);
    // Init Tables. Tables and ScrollPanes are delcared as final to enable access from within ListSelectionEvent
    // Table 1
    final JTable jTable1 = new JTable(model1);
    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp1 = new JScrollPane();
    sp1.setViewportView(jTable1);
    // Table 2
    final JTable jTable2 = new JTable(model2);
    jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp2 = new JScrollPane();
    sp2.setViewportView(jTable2);
    // Table 3
    final JTable jTable3 = new JTable(model3);
    jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JScrollPane sp3 = new JScrollPane();
    sp3.setViewportView(jTable3);
    // Add scrollpanes to panel.
    JPanel panel1 = new JPanel();
    panel1.add(sp1);
    panel1.add(sp2);
    panel1.add(sp3);
    // Add Panel to frame.
    JFrame frame = new JFrame("tableSelection");
    frame.add(panel1);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    // List Selection Listeners
    jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable1.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable2.getRowCount(); i++){
    if(jTable2.getValueAt(i, 0).equals(rowKey)){
    jTable2.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable2.getCellRect(i, 0, true);
    sp2.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable2.getRowCount() - 1)
    jTable2.clearSelection();
    for(int i = 0; i < jTable3.getRowCount(); i++){
    if(jTable3.getValueAt(i, 0).equals(rowKey)){
    jTable3.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable3.getCellRect(i, 0, true);
    sp3.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable3.getRowCount() - 1)
    jTable3.clearSelection();
    jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable2.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable1.getRowCount(); i++){
    if(jTable1.getValueAt(i, 0).equals(rowKey)){
    jTable1.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable1.getCellRect(i, 0, true);
    sp1.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable1.getRowCount() - 1)
    jTable1.clearSelection();
    for(int i = 0; i < jTable3.getRowCount(); i++){
    if(jTable3.getValueAt(i, 0).equals(rowKey)){
    jTable3.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable3.getCellRect(i, 0, true);
    sp3.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable3.getRowCount() - 1)
    jTable3.clearSelection();
    jTable3.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    // Get the first cell in the selected row, I call it "row key".
    String rowKey = jTable3.getValueAt(e.getFirstIndex(), 0).toString();
    for(int i = 0; i < jTable1.getRowCount(); i++){
    if(jTable1.getValueAt(i, 0).equals(rowKey)){
    jTable1.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable1.getCellRect(i, 0, true);
    sp1.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable1.getRowCount() - 1)
    jTable1.clearSelection();
    for(int i = 0; i < jTable2.getRowCount(); i++){
    if(jTable2.getValueAt(i, 0).equals(rowKey)){
    jTable2.getSelectionModel().setSelectionInterval(i, i);
    Rectangle rect = jTable2.getCellRect(i, 0, true);
    sp2.getViewport().scrollRectToVisible(rect);
    break;
    if(i == jTable2.getRowCount() - 1)
    jTable2.clearSelection();

  • Multiple row selection in ADF Table using addition column with checkbox

    I am using ADF table(Jdeveloper11g) and i want to selecte multiple rows it may be more than one OR all rows.
    For that i added one Column to the table with Header Delete and checkbox
    <af:table....
    <af:column sortProperty="Delete" headerText="Delete" width="100"
    sortable="false">
    <af:selectBooleanCheckbox label="#{row.favoriteId}"
    valueChangeListener="#{Mybean.onCheck}"
    id="checkbox" autoSubmit="true">
    </af:selectBooleanCheckbox>
    </af:column>
    </af:table>
    backing bean:Here i added code to get Value of one column with id favoriteId and use an arrayList(listForDelete) to monitor the state of the checkboxes
    public void onCheck(ValueChangeEvent valueChangeEvent) {
    BindingContainer bindings = getBindings();
    DCBindingContainer dcBindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding iterBind =
    (DCIteratorBinding)bindings.get("getUserFavoritesByUserIDIterator");
    if (iterBind != null && iterBind.getCurrentRow() != null) {
    RichSelectBooleanCheckbox ch = (RichSelectBooleanCheckbox)valueChangeEvent.getSource();
    if (!ch.isSelected()) {
    Long issueId = (Long)iterBind.getCurrentRow().getAttribute("favoriteId");
    listForDelete.add(issueId);
    else
    Long issueId = (Long)iterBind.getCurrentRow().getAttribute("favoriteId");
    listForDelete.remove(issueId);
    Problem is that when i select single row checkBox, onCheck() method of backing bean gets called multiple times(equals to the number of rows)
    I think this is beacuse of <af:selectBooleanCheckbox id is same that is "checkbox" but i am not sure.Even i tried to assign some unique id but no any success in assigning Id with value Expression.
    I also find related post
    Re: ADF Table Multiple row selection by Managed Bean
    but that is related to Select All rows or Deselect all rows from table.
    From the simillar post i follow the steps given by Frank.but problem with below step
    ->have an af:clientAttribute assigned to the checkbox with the following EL #{row.key} ,here I added <af:clientAttribute name="#{row.key}"></af:clientAttribute> and i am getting error
    Error(64,37):  Static attribute must be a String literal, its illegal to specify an expression.
    Please let me know if any one had already implemented same test case.
    Thanks for all help
    Jaydeep
    Edited by: JaydeepJ on Aug 7, 2009 4:42 AM

    just to update after the rollback is called in the cancel button i wrote following code which does not change the row focus to the first row
    DCBindingContainer bc =
    (DCBindingContainer)BindingUtils.getBindingContext().getCurrentBindingsEntry();
    DCIteratorBinding profItr =
    bc.findIteratorBinding("ProfileSearchInstIterator");
    Row cRow = profItr.getRowAtRangeIndex(0);
    if(cRow != null){
    System.out.println("Current row is not null so fixed ");
    profItr.setCurrentRowIndexInRange(0);
    RowKeySetImpl rks = new RowKeySetImpl();
    ArrayList keyList = new ArrayList();
    keyList.add(cRow.getKey());
    rks.add(keyList);
    profileTable.setSelectedRowKeys(rks);
    AdfFacesContext.getCurrentInstance().addPartialTarget(profileTable);
    }

Maybe you are looking for

  • How can I use sql loader to load a text file into a table

    Hi, I need to load a text file that has records on lines tab delimited into a table. How would I be able to use the sql loader to do this? I am using korn shell to do this. I am very new at this...so any kind of helpful examples or documentation woul

  • How can you get apps back after you restore an iPod?

    Alright so basically I was on my iPod using an app when all the sudden my screen goes black and it wouldnt turn back on, when I inverted colours it went white so my iPod was on, just not responding. I had to restore my iPod and I have all my music ba

  • Sharing photos via MobileMe Gallery - what alternative?

    I have been sharing photos with my soon to be 80 years old mother via my MobileMe gallery, all I had to do was send her the link, while all she had to do was subscribe to my gallery in order to have the images download to iPhoto. This was easy and st

  • Webcam/Audio Input

    I am admittedly an amateur at Actionscript, but I'm trying to produce an example of Flash's ability to process video/microphone data as a "jumping off" point for other projects. My problem is: I am using some open source to pick up web cam movement a

  • Error Occures while Passing Data

    Hi All, I am making an ADD-On Form by using VB.Net 2005 on its DI API portion. And its UI API portion is designed in XML. This Add-On has an Matrix on it, which store item details. Now while I am going to choose Items from ItemList , after selecting