Adding new rows to table - using TableRowSorter & RowFilter

Hi all,
I have a table where the user can add new rows by selecting a JButton. I have added a text box which allows the user to search for a String value and this filters the table contents and this is all working fine...But when I go to add a new row I get the following exception:
java.lang.IndexOutOfBoundsException: Invalid range which seems to originate from DefaultRowSorter.rowsInsertedCould someone please give me any ideas to why this is happening, maybe the number of rows that are in the table orginally is set to x and when I add a new row the TableRowSorter is expecting that number not x + 1 which is added due to the button being pressed?
Seems like I need to update the TableRowSorter to inform it that a new row has been added or something similar to that,
Thanks,

If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

Similar Messages

  • Null Pointer Exception When Adding New Row on Table

    Hello JheadStart Team
    I have used detail group with table layout , when I am clicking on AddRow button on detail table , I encounter NulllPointer Exception . I have traced the code and fount that in JhsCollectionModel when adding new row following
    condition occurs :
    DCIteratorBinding ib = getRangeBinding().getIteratorBinding();
    int rangeSize = ib.getRangeSize();
    int rowsInRange = ib.getAllRowsInRange().length;
    because getAllRowsInRange is Null then the error raise.
    My JheadStart ver is 10.1.3.3.85 .
    Detail Group with table layout setting is :
    Use Table range=true
    Show New Row at top=true
    New Rows:empty
    Show Add New Row Button :true
    Regards

    Given the build you are using, I assume you are an Oracle employee.
    Is this correct? if so, please post your question to the [email protected] mailing list.
    Steven Davelaar,
    JHeadstart team.

  • How to refresh the grid so that default  values come on adding new row.

    Hi Experts,
    In alv grid while adding new row, i want some 2-3 column values to come by default from already existing row in grid.
    i am getting new row in internal table with 2-3 default values and rest columns blank on adding new row in alv grid
    but the entire row is coming blank, not able to get the default values in new row
    how can i refresh the grid so that default  values come on adding new row.
    thanks

    Hi Surabhi,
    Use this in Interactive section even if you are doing simple ALV.
    DATA:
    lv_ref_grid TYPE REF TO cl_gui_alv_grid.
    CLEAR : gv_tcode.
    *-- to ensure that only new processed data is displayed
    IF lv_ref_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
    e_grid = lv_ref_grid.
    ENDIF.
    IF NOT lv_ref_grid IS INITIAL.
    CALL METHOD lv_ref_grid->check_changed_data.
    ENDIF.
    THis will solve your problem.
    Regards,
    Vijay

  • Adding a Row to Table, ComboBox as a  TableCellRenderer Problem !!

    Hell All:
    I have a JTable with one of the Cell as ComboBox. Initially I draw the JTable with Three Rows and the
    the ComboBox in the Second Column works fine. I see each comboBox has different Items. The ComboBox also has a Renderer (as I am customizing the Item's Text )
    Here is the snippet from my Code.
    ==========================
    // UIEditSubAllocation.ALT_ACCOUNT = 2;
    // Get the Viewindex.... to get the correct column
    int viewIndex = this.m_suballocTable.convertColumnIndexToView(UIEditSubAllocation.ALT_ACCOUNT);
    // get the Table Column...
    TableColumn altActColumn = this.m_suballocTable.getColumnModel().getColumn(UIEditSubAllocation.ALT_ACCOUNT);
    // Create Three ComboBox..
    JComboBox[] altActCell = new JComboBox[3];
    for (int i =0;i< 3;++i) // adding Three Rows of Table Data...
    String [] alternateAccounts = new String[4];
    for(int j = 0; j < alternateAccounts.length; j++) // Each Alternate Accounts i.e combobox has 4 items..
    alternateAccounts[0] = "Tom";
    alternateAccounts[0] = "Vic";
    alternateAccounts[0] = "Tracy";
    alternateAccounts[0] = "Andy";
    altActCell[i] = new AltAccountComboBox(alternateAccounts,this.m_suballocTable);
    } // End of adding Three Rows
    altActColumn.setCellRenderer(new AltAccountTableCellRenderer());
    if (viewIndex >= 0)
    ComboBoxEditor altActCellEditor = new ComboBoxEditor(altActCell);
    altActColumn.setCellEditor(altActCellEditor);
    The CombBoxEditor code is...
    ublic class ComboBoxEditor extends DefaultCellEditor
    * Constructs a ComboBoxEditor that uses an array of items of type object.
    * @param items - an array of items of type object
    public JComboBox[] m_comboBox;
    public ComboBoxEditor(JComboBox[] box)
    super(box[0]);
    m_comboBox = box;
    for(int i = 0; i < box.length; i++)
    m_comboBox.setEditable(false);
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
    if(row >= this.m_comboBox.length)
    return super.getTableCellEditorComponent(table, value, isSelected, row, column);
    return m_comboBox[row];
    But when I click a Button (in a Panel) which adds a Row (with No values for the ComboBox ).. to the Jtable .. The Row Gets added fine.. but the JComboBox comes with Values from the First Row's ComboBox. I Don't want any Values in the JComboBox for the new added Row. Can someone tell me
    how do I remove the Items from the ComboBox.
    I will really appreciate for any help...
    Thanks
    -Pankaj

    Hi ,
    as per my opinion one approach would be that ,
    you create a custom table region same as standard one using Jdeveloper and create other required fields also using jeveloper ,and then put this region in extend property of existing standard table region .
    thanks
    Pratap

  • Can iOS Numbers copy formulas when adding new rows?

    iOS Numbers table add row is not copying previous cell formulas. Is this supported or not?
    I have a table with lots of columns and all of them have formulas. When I click at the lower left of the table to add a row, none of the new cells have the formulas. I have to manually go through every column and copy the formulas to the new row.
    This is not very practical if you're planning to use Numbers on the go with an iPad. In my case, I have to quickly get a new row ready as needed. I was hoping there is a preference setting somewhere like "copy formulas when adding new row".

    I had the same issue with the added twist that I wanted to reference the created cells in formulas in other sheets. This is what works for me:
    I use a form to enter data. The referenced sheet is set up like this:
    1     Name     Date     ServPayment    SalesPayment     Total
    2     Week1                                                                 =sum (ServPayment,SalesPayment)
    3                                                                                =sum (ServPayment,SalesPayment)
    4     TotWeek1                                                            =sum (Total2,Total3)
    "Total" sums the 2 Payments, TotWeek1 sums the totals.
    In the entry form I never add data to the empty line. In this example, I would start at "Week1" and tap the "+" to add a new form. This creates the line in the referenced sheet with my formulas. As I continue, I always start at the last entry I have made and tap "+".
    When I create a line that does not have the formula on either side, I do not get the formula.
    Hope this helps.

  • EDIT method doesn't work after adding new row

    I would like to start editing after adding new row into TableView.
    I copied example from Oracle website: [Using JavaFX UI Controls - 13 Table View|http://docs.oracle.com/javafx/2/ui_controls/table-view.htm#CJAGDAHE]. Then I put additional button for adding new row and define action for the button.
        final Button addButton = new Button("Add");
        addButton.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent arg0) {
                Person p = new Person("", "", "");
                table.getItems().add(p);               
                table.getSelectionModel().select(p);
                table.edit(table.getSelectionModel().getSelectedIndex(), table.getColumns().get(2));
        });In result I can see selected new row but the table doesn't start edditing in the third column.
    I have similar method for editing existing rows and it works properly.
        final Button editButton = new Button("Edit");
        editButton.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent arg0) {
                table.edit(table.getSelectionModel().getSelectedIndex(), table.getColumns().get(2));
        });Could you help me what I do wrong?

    Try wrapping the setCaretPosition(...) method in a SwingUtilities.invokeLater(...)
    caret=outputArea.getDocument().getText(0,outputArea.getDocument().getLength()).length();Should be:
    caret = outputArea.getDocument().getLength();

  • Adding data to multiple tables using one form in Access 2010?

    Hi All,
    I have a access database with two tables and I want to create a single form to enter data into that tables.
    How to adding data to multiple tables using one form in Access 2010?
    I don't have to much knowledge of access database?
    Please help me
    Thanks
    Balaji

    You really don't enter identical data into 2 tables.  You enter dat into one single table, and then you have an unique identifier that maps to another table (you have a unique relationship between two tables). 
    Maybe you need to read this.
    http://office.microsoft.com/en-001/access-help/database-design-basics-HA001224247.aspx
    Think about it this way...  What is you update data in 2 tables, and then the data in one of those tables changes, but the data in the other table does NOT change.  WHOOPS!!  Now, you've got a BIG problem.  For instance, you have a customer
    named Bill Gates.  In one Table you update Bill's address to 1835 73rd Ave NE, Medina, WA 98039 and in the other table you accidentally update Bill's address to 183 73rd Ave NE, Medina, WA 98039.  Now you have 2 addresses for Bill.  Why would
    you want that???  Which is right?  No one knows.  If you have one address, you just have to update one address and if there is a mistake, you just have to update one address, but you don't have to waste time trying to figure out which is right
    and which is wong...and then update the one that is wrong.
    Post back with specific questions.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • ADF Popup for adding a new Row in  table

    Hi All,
    I have VO which is rendering as table on my jsff.I created a button of createInsert to add a new row and after commit it saves the values in Table in DB.
    Works abst fine.
    Now i want to change this feature to that when a New Row should be Added, a pop up should appear in the format of a form, and at the click of OK it should save the data and on Cancel go back to Page.
    What i did was i added a pop up, in the pop up body i again dropped my VO as a form and added a dialoglistener to the pop up which commits on click of OK and Rollback on click of Cancel.
    I am not getting any exception but The Db is not modified with my entries.
    So its simple that i am commiting but nothing is changed till that time.
    How can i get the Task done?????
    Regards
    User

    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/77-ok-cancel-support-in-dialog-351871.pdf
    insert operation using popup
    http://andrejusb.blogspot.com/2009/11/crud-operations-in-oracle-adf-11g-table.html
    Edited by: Erp on Oct 20, 2011 6:47 AM

  • Adding new row in a table

    hi experts ,
    i am working on a table and on an action of button i need to add a row. The table has a lots of elements like input fields, dropdown by key, textviews etc. i have created a new row by incresing visible row count on action but the above mentioned elements are not editable . The cardinality of the node bound to table is 1..n and selection is 1....n.
    Please suggest me a proper solution.
    Thank you.

    Hi,
    Try this code,
    IPrivatePopUpMenuView.IProductsElement ele=wdContext.createProductsElement();
                   ele.setProductId(str1);
              ele.setQuantity(str2);
              ele.setPrice(str3);
              ele.setName(str4);     
              ele.setDetails("Detailed discription for  "+str4);
              wdContext.nodeProducts().addElement(ele);
    Here str1 str2 are all the value which unwant to add to table.
    Regards,
    H.V.Swathi

  • Add New Row in Table on click of a button

    Hi All,
    I am using JDeveloper 11.1.5
    I have a af:table with a detailFacet. In this detailFacet there is an af:commandButton. On click of this commandButton I want a new row to be added to the table programmatically.
    In my Backing Bean I have following code for my button:
    public String cb1_action() {
    // Add event code here...
    //RowKeySetImpl rowKeySet = new RowKeySetImpl();
    CollectionModel tableModel = (CollectionModel)t1.getValue();
    JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
    DCIteratorBinding tableIteratorBinding = adfTableBinding.getDCIteratorBinding();
    // DCDataRow rw = (DCDataRow)tableIteratorBinding.getRowSetIterator().createRow();
    // tableIteratorBinding.getRowSetIterator().insertRow(rw);
    Row lastRow = tableIteratorBinding.getNavigatableRowIterator().last();
    Row newRow = tableIteratorBinding.getNavigatableRowIterator().createRow();
    newRow.setNewRowState(Row.STATUS_INITIALIZED);
    int lastRowIndex = tableIteratorBinding.getNavigatableRowIterator().getRangeIndexOf(lastRow);
    tableIteratorBinding.getNavigatableRowIterator().insertRowAtRangeIndex(lastRowIndex+1, newRow);
    tableIteratorBinding.setCurrentRowWithKey(newRow.getKey().toStringFormat(true));
    AdfFacesContext.getCurrentInstance().addPartialTarget(t1);
    return null;
    On running this ,I get an Exception some thing like UnsupportedOperationException.
    Please help me to find where I am wrong.

    Take a look at this post which could provide solution for your use-case:
    http://mjabr.wordpress.com/2011/07/02/how-to-control-the-location-of-the-new-row-in-aftable/
    Thanks,
    Navaneeth

  • Problem with deleting a new row in table

    Hi
    I'm using JDev 11.1.1.2.0
    Please someone tell me if he/she experience the same issue:
    - I have an simple entity with PrimaryKey other than RowID. I have a ViewObject on top of the Entity.
    - From this view I create Editable table and add createInsert and Delete buttons.
    This is one of the most common scenarios.
    Now when I click createInsert a new blank row is added to the table. I enter it's primary key (because is mandatory) and move selection to some other row (let say X).
    When I go back and select my new Row and press Delete -> it is not deleted but the row X is deleted.
    This is because the table is not refreshed and it cant select the new row.
    How can I deal with this problem?
    Thanks
    Angel

    I tried with adding my selectionListener method like this:
            Object next = selectionEvent.getAddedSet().iterator().next();
            Object prev = selectionEvent.getRemovedSet().iterator().next();
            System.out.println(prev + " " + next);      
            DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
            DCIteratorBinding iter = (DCIteratorBinding)bc.get("TestDopSyotvIterator");
            FacesCtrlHierBinding object1 = (FacesCtrlHierBinding)bc.get("TestDopSyotv");
            FacesCtrlHierBinding.FacesModel collectionModel = (FacesCtrlHierBinding.FacesModel)object1.getCollectionModel();
            collectionModel.makeCurrent(selectionEvent);I add new row, enter data and change selection. Then the system.out prints the right keys of the rows.
    But when I go back to the new added row, the system.out prints "null" for the "next" value (that means the rowKey was lost).
    Any ideas how to fix this?

  • Tabular form - adding new row

    Hi,
    I have a very simple table (5 rows, 1 of which is the primary key), and want to update the table using a tabular form. On initial display, the primary key column is protected (cannot be changed) which is ok for DELETE and UPDATE options, but when I come to ADD A NEW ROW, the new row has NULL defaulted as the primary key value, and will not let me update it !!
    Does anyone know how I can leave the primary key column protected when UPDATING or DELETING, but allow a value to be entered when ADDING A NEW ROW ?
    thanks
    Tim

    Andy,
    Just made the following changes (to remove NARR1_CODE_DISPLAY and show and edit NARR1_CODE):
    select
    "NARR1_CODE",
    --"NARR1_CODE" NARR1_CODE_DISPLAY,
    "NARR1_LOWER_LIMIT",
    "NARR1_UPPER_LIMIT",
    "NARR1_RMP_MIDPOINT_1",
    "NARR1_RMP_MIDPOINT_2"
    from "#OWNER#"."DQ_PD_TRANS_DIST_BAND_NARR1"
    where the column NARR1_CODE is my primary id, and in the report attributes, NARR1_CODE is now editable and shown as a "text field" . NARR1_CODE_DISPLAY has been removed.
    However, when I go into my form screen, although the NARR1_CODE field is now editable, when I click ADD NEW ROW, enter the details for a new row, check the box alongside the new row and click SUBMIT, I get the following error message :
    Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-20001: ORA-20001: Current version of data in database has changed since user initiated update process. current checksum = "A884FA378C851786DDFE3A33709CB23C", item checksum = "F6395FDACE39D98E784F85C19D960620"., update "GRD_DD10_OWNER"."DQ_PD_TRANS_DIST_BAND_NARR1" set "NARR1_CODE" = :b1, "NARR1_LOWER_LIMIT" = :b2, "NARR1_UPPER_LIMIT" = :b3, "NARR1_RMP_MIDPOINT_1" = :b4, "NARR1_RMP_MIDPOINT_2" = :b5
    sorry about this !
    thanks

  • While creating a new row in table,the total data present in table is coming

    Hi,
    From search page,i click add button,it goes to next transaction page.In transaction page i drag and drop one VO in table and in form also.But in that transaction page,The table is coming with data and a new row is also able to insert.But i don't want the previous data whatever present in table in create a new row time.Please give me the solution.
    Thanks in advance
    Sravanthi

    Not sure I understand what you are trying to do.
    If you have a table and a form based on the same data on one page you see the already existing data in the table. If you don't want to see the existing data in the table while entering a new row, the simplest solution would be to
    a) hide the table after the use hits create new row or
    b) navigate to an other page which only shows the form
    Timo

  • Inserting new row in Table in 11.1.2 from 11.1.1.3 not rendering table!!!!!

    Hey Guys, my status might say noob but i am well seasoned in ADF. We migrated from 11.1.1.3 to the new JDEV 11.1.2. We are doing a test run before we commit to it.
    I noticed the following:
    We have master detail forms that work flawlessly in 11.1.1.3 when we ran the app under 11.1.2 we noticed that any time you try to add a new row to a table the table does not render. The server logs show the action going through and the count goes up one but the table is not rendered anymore it disappears!!!!!!!!!!!!!!
    Now all of this was imported from the 11.1.1.3. all of our tables that have createInsert actions on them are doing this.
    If i drag the tables again and set them up from scratch it seems to work fine. Our issue is we have a good 300 of these tables in different panels and panel collections. we have to do all of that work all over again.
    No errors show in the log. IS THIS A BUG???????????????
    UPDATE: REFRESHING THE PAGE using the Browser Refresh Button Will show the new ROW....... THIS IS NOT GOOOD!!!
    Edited by: user8333408 on Jul 7, 2011 9:23 AM
    Edited by: user8333408 on Jul 7, 2011 9:24 AM
    Edited by: user8333408 on Jul 7, 2011 10:08 AM

    Thanks for the reply.
    The Project was in version 11.1.3 before I migrated. I had the issue above so I migrated to 11.1.1.4 then to 11.1.1.5 then to the New GREAT 11.1.2 to go by the matrix of support The issue is still there.
    Basic Page layout:
    SEARCH-MASTER-PANELTABBED LAYOUT (Hold all the CHILDREN RECORDS)
    PANEL TAB is made of ; SHOW DETAIL ITEM- PANEL COLLECTION- TABLE.
    the panel collection has a toolbar with 2 buttons in it.
    My issue varies:
    Hit create insert==> record count goes up one but the table does not render (it goes all blank even if records existed in it)
    Hit undo budo ==>table still not rendering. (click next on master record then click previous to come back, the table renders correctly.)
    other tables do the following:
    Hit Create insert == > table shows normally and I can enter new record.
    Hit undo ==> table count goes down but table does not render at all anymore.
    for this issue i noticed if i set cache results to false the table works after hitting undo
    IF I CREATE A NEW SHOW DETAIL ITEM and put exactly what the other tabs have in them and use the same layouts and buttons the new table works great!!!!!!!!!!!!???????????????????? WTF?!?!?!?!
    NO ERROR MESSAGES even at finest level are thrown.
    I HAD NO ISSUES IN THE PREVIOUS VERSIONS OF JDEV IS THIS A JSF 2.0 BUG????
    BY THE WAY JDEV 11.1.2 sometimes CRASHES or Hangs when viewing the Binding of Page when you click on Binding straight from the Design view. I have to open the Binding Page separate to view it. FYI
    Edited by: Nottallah on Jul 11, 2011 9:48 AM
    Edited by: Nottallah on Jul 11, 2011 9:51 AM

  • Add new row in table between two rows - OATableBean

    Hi,
    I have a requirement where I need to add a new row between two rows. Lets say I have a table with 5 rows. I am envisioning having an icon (table switcher) on the row #1, which when clicked will insert/create a new row between rows #1 and #2 like #1.5, something that can be achieved in core forms. In core forms, when we click the add button, it immediately creates a new row before the current row ( and pushes other rows down). Is that possible with OATableBean. Please let me know if you have any ideas.
    Thanks,
    Ravi.

    Hi,
    I used following code to insert the row in the end
    public void createNewRow()
    XXEGASRLinesVOImpl vo =getXXEGASRLinesVO1();
    Row row1 ;
    int i;
    Row row[] = vo.getAllRowsInRange();
    row1 = vo.createRow(); //vo.createRowSet("10");
    vo.insertRowAtRangeIndex(row.length,row1);//.insertRow();
    row1.setNewRowState(Row.STATUS_INITIALIZED);
    Check if it works for you, you have to modify it to meet your requirement.
    Regards,
    Reetesh Sharma

Maybe you are looking for