How to insert and delete a row after filter applied

I thought I had figured out the solution to this problem but apparently not...
How do you insert a new row into a JTable after a filter has been applied? The problem is once the data is filtered when I add a row, I'm getting an ArrayIndexOutOfBoundsException : 182 which is the number of rows for the entire dataset.
The first line in the exception is: DefaultRowSorter.setModelToViewFromViewToModel
I've tried to use, getRowSorter().convertRowIndexToView(int) but I can't get it to work. Can anyone offer any assistance?
Thanks

I also got that problem recently and after debuging for a while I figured out, that it was resulting from an error in my table's model: When the model received new items to display I
1.) Fired an delete event for the old items
2.) Fired an insert event for the new items
Problem was that when firing the delete event I didn't already assigned the new items to the model. Therefore it had still the old row count.
Maybe you have also a faulty table model?...

Similar Messages

  • Web Dynpro for ABAP:How to insert and delete a row in a table

    I have a table.
    My requirement is to insert a row into the table and i want to delete a particular row also.
    How can i do it.
    Plz reply me..

    Try the Web Dynpro for ABAP forum:
    Web Dynpro ABAP
    Kind Regards
    Stefanie

  • How to find and delete matching row in ADF BC

    Hi,
    I have a table with simple fields and I have created the java class for this entity also
    Person
         - Person_Id (PK)
         - Person_NameI wanted to create an application module method to search for the entity that matches certain name
    but I cant find the code to do this.
    public class AppModuleImpl{
      public boolean deletePersonByName(String personName)
        EntityDefImpl personDef = PersonImpl.getDefinitionObject();
        //How to get all rows and find the matching name then delete the row
        return false;
    }Thanks
    Jdev 11.1.1.5

    Ramandeep Nanda wrote:
    getfilteredRows does that, you can iterate and delete the rows after filtering on any attribute in view object it does not have to be a primary key.Hi Ramandeep,
    I got the idea and I somehow was able to do what I want.
      public boolean deletePersonByName(String personName)
        PersonViewImpl personView = this.getPersonView();
        Row[] matchingRows = personView.getFilteredRows("PersonName", personName);
        if(matchingRows!=null)
          for(Row rowTemp : matchingRows)
            PersonViewRowImpl personRow = (PersonViewRowImpl) rowTemp;
            personRow.remove();
            try
              getDBTransaction().commit();
            }catch(JboException ex)
              throw ex;
        return true;
      }But somehow I got this idea, supposed I have this data
    PersonId          PersonName
    1               MANDER
    2               MANDERRY
    3               JERRYThe code getFilteredRows somehow only perform an 'exact' match but what if I want to delete both of the data
    with PersonName 'MANDER' above.
    My current code only removes the person with name 'MANDER' and not the 'MANDERRY'
    Thanks

  • How to insert and delete fragments by clicking a button and how to script it?

    I have a  question on livecycle. I am collecting the inventor information as a bunch of text fields, each asking for a certain details. Please see below
    Now I have grouped them all in to one fragment called inventordetails and saved as .xdp file, so I could reuse this entire block. I want to add a button underneath this block, “ADD MORE INVENTORS” and when clicked this will insert another block and so forth and so on. However I was not sure as to how to insert and delete a fragment. Do  you think you can help with this? I appreciate any help in this regard.
    Best
    Subashini

    1.       I have a subform1 which is flowed
    2.       I have subform2 inside subform1 which is positioned
    3.       Inside subform2 I have two buttons 1. ADD INVENTOR 2. DELETE INVENTOR
    4.       Also inside subform1 I insert a fragment called inventor
    Now I want to script the buttons so that when clicked the inventor fragment either gets inserted again or deleted.
    I greatly appreciate any help in this regard.
    Best
    Subashini

  • How to Add and delete a row while using Abstract Table Model

    Hi,
    I need to do the following functionalities in JTable.I've done tht but a small problem.
    1. Adding a row (Using addRow() method from DefaultTableModel).
    2. Deleting a row(Using setRowCount() method from Default Table Model).
    3. Sorting the table based on the selection of column(Using TableSorter which is using AbstracTableModel).
    As the sorting is mandatory i've to change my model to Abtract Table Model
    The problem is this Abstract Table Model doesn't have any methods to Add a row or deleting a row (setRowCount()).If anybody has written any utility method for this using Abstract Table Model help me.

    Using TableSorter which is using AbstracTableModel).If your talking about the TableSorter class from the Swing tutorial, then you create the TableSorter class by passing it a TableModel. There is no reason you can't use the DefaltTableModel.
    I changed the code in TableSorterDemo as follows:
            String[] columnNames = {"First Name",
                                            "Last Name",
                                            "Sport",
                                            "# of Years",
                                            "Vegetarian"};
            Object[][] data = {
                {"Mary", "Campione",
                 "Snowboarding", new BigDecimal(1), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new BigDecimal(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new BigDecimal(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new BigDecimal(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new BigDecimal(10), new Boolean(false)}
              DefaultTableModel model = new DefaultTableModel(data, columnNames)
                   public Class getColumnClass(int c)
                        return getValueAt(0, c).getClass();
            TableSorter sorter = new TableSorter(model);
    //        TableSorter sorter = new TableSorter(new MyTableModel()); //ADDED THIS

  • ALV_GRID How to get number of lines after filted applyed?

    Hi, all!
    The task is to display title in alv_grid like
    "N records selected (X records on the screen)".
    It means, N records in dataset and X records displayed after  filter applyed by user.
    But i can't get number of lines after filter applyed from the alv_grid.
    Can anybody help me?
    Thanks & regards,
    Konstantin

    Hi,
    If it goes through PBO/PAI cycle after user sets the filter then in your PBO call method get_filtered_entries of CL_GUI_ALV_GRID and then do a describe statement on the table.
    Number of entries in your grid table - number of entries in this filtered entries table will give you the displayed entries after the filter is set.
    If it does not go through PBO/PAI cycle then register for after_user_command and I think the fcode for filter is '&FILTER' and code for the above logic in your handler method..
    Hope this helps..
    Sri

  • How to get Inserted and Deleted Rows in ALV

    I have looked at the BC_EDIT* examples but I still can't figure out how to determine which rows were Inserted and Deleted from the ALV list.  Can someone please provide me the code to do this?
    Thanks.
    Sandy

    Hi sandy,
    i dont think you will have issue in inserting a row in ALV because whenever the user done some actions say for eg clicking the pushbutton at the toolbar you could insert the a new row into the ALV.for creating pushbutton you need to use the events TOOLBAR,USER_COMMAND.
    deleting a row may also follow the above procedure.
    Have a look at the demo program
    BCALV_GRID_05
    Cheers,
    Abdul Hakim

  • How do I insert and delete pages from a pdf with acrobat 10X?

    How do I insert and delete pages from a pdf with acrobat 10X?

    Alternatively, be sure your page thumbnails panel is open, and click on the icon highlighted in this image, just under the heading.
    You will see a dropdown with the options you need.

  • Can we have an example of using update, insert, and delete stored procedure

    I would like to see an example of using retrieve (return resultset), update, insert, and delete stored procedures in JSF. I need to see syntax how JSF can call those stored procedures. This option is absolutely important when building web-application. Currently, I haven't found resource to do for this purpose yet. The database can be any such Oracle, DB2, pointbase, etc that support stored procedures.
    Anyone knows?
    Thanks,
    Tue Vu

    Hi ttv,
    I asked around a bit and here's some more info:
    To bind a ResultSet to a read only Data Table component just set the "value" property of the Data Table component to point at it, and JSF will synthesize a DataModel around it.
    * Note that because we can't call the stored procedure at design time, Creator can't do the fancy table layout stuff it does for rowsets. You'll need to hand craft the columns just like the Google Client example.
    * As I mentioned previously, you will have to manually code the stored procedure access in your java code - see the code clip I mentioned in previous reply (and if this is via a stored procedure, then any textbook about JDBC will undoubtedly have examples). Simplest way might be a getter method on the page bean that contains the call to the stored procedure and returns the resulting ResultSet object.
    * Don't forget to close the result set - we typically do this at the end of the request (i.e. add a close in the afterRenderResponse() method.
    * Don't throw exceptions - or if you have to, make sure you close the result set in a finally clause (thrown exceptions bypass the afterRenderResponse method in the lifecycle).
    * You give up on the caching provided by our RowSetDataModel (which can't be connected to a ResultSet even manually), so I would recommend that you only use datatables to display the data and then go to a single row page to do edits/deletes (similar to the TwoPage example in AppModel and the Update, Insert Delete tutorial).
    And yes please do submit an example - we will gladly post it!!! :) The best way to submit this kind of thing would be through:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
    on the right side, Related Links, under Creator Heros, click Submit Content and there you can send it in!
    Hope this helps!
    Val

  • Insert and Delete at the same time?

    Hi,
    I have a dynamic list and dynamic form. When a person inserts a record using the dynamic form, I would like to delete a record from another table using a foreign key when the new record is added (assuming a record exists in the other table). Is this achievable, and if so, can anyone provide any help?
    Thanks in advance for any advice provided.
    Gary

    As kendenny says, this appears to be a misunderstanding of how database transactions work.
    As Hoek says, if it's an insert and delete on the same table, there is a MERGE statement that can help do that as a single statement.
    However, you do not do an INSERT from one table and a DELETE at the same time from another table.  But that doesn't matter, because that's the point of logica transactions on a database.
    You perform your insert, which starts a transaction (if one isn't already started).
    You then delete from your other table (which adds to the transaction)
    When you're happy that both things are done, you COMMIT your transaction which then applies those changes.
    If you're not happy with something you can ROLLBACK, and that will undo all the changes from the transaction.
    So, the commit and rollback allow the changes to be applied as one logical unit, even though the changes are applied in multiple steps.

  • Insert and Delete Button related code

    Hi Expert,
    I have requirement to create custom assignment block with custom table (value node), and add two button "Insert" and "Delete" on that AB.
    I have created the custom AB and button in "DO_PREPARE_OUTPUT" method.
    I need to create event handler for EH_ONINSERT and EH_ONDELETE, once the user click on "Insert" button one row editible row should append on AB and similar way if user select any row in AB and click on delete button entry should be deleted from AB.
    And i need "SAVE" button on top on overview page so entry should get saved in table.
    Regards,
    Kapil

    Hi Kapil,
    You can refer below mentioned link for your web ui related developments.
    SAP CRM WEB UI : 48.ADDING EDIT,CANCEL AND SAVE BUTTONS TO THE OVERVIEW PAGE TOOLBAR
    Rgds
    Hari

  • Adding and Deleting Multiple Rows or Columns

    How do you add or delete more than one row or column at a time.

    Robby! wrote:
    That's a great finding!
    I just wrote a feedback requesting a shortcut like this.
    It is a pity though that they desing it to work only if you select the header of the row/column. It should be enabled to work from within any cell in the table.
    Who wrote such an error ?
    These interesting shortcuts behave flawlessly even if the cursor was in D18 for instance.
    (a) I never saw them in the delivered resources.
    (b) they aren't responding to the OP's question which was about "Adding and Deleting Multiple Rows and Columns"
    Yvan KOENIG (from FRANCE vendredi 3 octobre 2008 18:39:01)

  • How to archive and delete messages in SXMB_MONI

    Hi all,
    We are working on SAP XI Development environment wherein we have File to IDoc scenario running twice daily and creating many messages.
    How to archive and then delete these messages ?
    Does accumalation of past messages affect the speed and performance of the system?
    Thanks in advance.
    Ajay

    Ajay,
    For step by step procedure of how to archieve and delete messages in XI go through the urls:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/402fae48-0601-0010-3088-85c46a236f50
    Delete Messages SXMB_MONI
    http://help.sap.com/saphelp_nw04/helpdata/en/0e/80553b4d53273de10000000a114084/frameset.htm
    Too many questions on Archive/Delete messages.
    ---Satish

  • How to find and delete duplicate photos in photo app

    how to find and delete duplicate photos in photo app

    Photos has no built-in tools to screen the library for duplicates. It relies on the warning on import, that should prevent you from importing duplicates.
    Once duplicate shave been imported, delete them manually, or use third-party tools.
    For example, these new apps claim to work with Photos:
    Power photos:  Fat Cat Software
    Duplicate annihilator: Brattoo Propaganda Software - Products
    PhotoSweeper: http://overmacs.com/photosweeper.html

  • Add and Delete a row in table

    Hi Expert,
    In SAP interactive form OFFLINE Scneario.
    I have a deep structure. In which i am using other structures like kna1, knb1, knvv.
    Now in KNVV is again a deep structure in which i have a table type.
    Now a draged and droped this table type to my layout  so i got a table.
    I Need to have two buttons ADD and Delete, To add and delete a row in table repectvily.
    I saw other threads also but get not do it.
    My table type attribute's name in KNVV structure is VLACT.
    I write following code on click action of ADD button
    data.#subform[0].Button1::click: - (FormCalc, client) -
    VLACT.row.instanceManager.addInstance(1);
    xfa.form.recalculate(1);
    but it shows error msg
    accessor "VLACT.row.instanceManager.addInstance(1);"
    is unknown.
    Also i am not able to see tabel itself wich i draged and droped. Only two buttons are there.
    Plz help
    Thanks ? Regards,
    Arvind

    Hi Otto,
    This is the code i am using to add new row.
    Also all the settings in form are correct like "Repeat row for each data item" etc.
    I want to have at most 7 rows.
    var nTableLength = Table1.nodes.length; 
      var nNumRow = 0;
        for (var nCount = 0; nCount < nTableLength; nCount ++)
          if ((Table1.nodes.item(nCount).className == "subform") & (Table1.nodes.item(nCount).name !== "HeaderRow"))
           { nNumRow = nNumRow + 1; }
               if (nNumRow == 7)
               { xfa.host.messageBox("The maximum allowable number of rows is 7. You cannot add any more rows.", "Warning", 3); }
           else {
                  Table1.Row1.instanceManager.addInstance(1);
                  xfa.form.recalculate(1);
                   xfa.host.messageBox("row added" );
    I get the msg form the statment        xfa.host.messageBox("row added" );
    But i can not see the newly added row
    Plz help
    Thansks & Regards,
    Arvind

Maybe you are looking for

  • 4.2.2 upgrade from 4.1 and images location issue

    I've just upgraded from 4.1 to 4.2.2, and am having an issue with the referenced location of the images directory (/i/) resources. I am running apex listener on weblogic server, and have copied the new images into the i.war that I use. I have an unus

  • Mac Pro Boot Problems. Kona 3?

    I'm having booting problems with a Mac Pro. It's got a kona 3 card in one of the PCI slots, and we've been tinkering with it to try to get the audio to work right. However, I've been having huge problems whenever I try to restart the computer. After

  • Add editable fields in smartforms

    Hi, I'm working with smartforms (CRM) and i wonder to know if its possible to create a kind of blank fields that allow the user to insert some free text right before print the form? Thanks a lot in advance, Nuno Moreira

  • Is there a way to do a virus scan on an ipad

    MY iPad is slagging and delays when using the keyboard, as well as, in messages it doesn't let me see my most recent messages or what I am typing, and my iPad keeps freezing in different webpages. spSo my assumption would be a virus, but I don't know

  • Plot mixed graphs

    Post Author: dufernandes CA Forum: .NET Hi there, My problem is the following: I'm using MS Visual Studio 2005 with the standard version of Cyrstal Reports. I wish to design a bar chart along with a line chart (that represents the goal of the data be