FireTableRowsInserted(ind,ind) without adding a new row consequnces?

Hello all,
I am looking at code where someone is calling fireTableRowsInserted(index,index) when there is no new row being inserted or deleted?
What are the consequences when the above happens?
Does anything abnormal happen?
Method a
if(bool)
fireTableRowsInserted(0,0);
else if(bool2)
else if(bool3)
fireTableRowsInserted(0,0);
What will happen if bool is true?
fireTableRowsInserted will be called twice but there is only one row added!
Edited by: javapunt on Jun 24, 2008 9:08 AM
Edited by: javapunt on Jun 24, 2008 10:03 AM

camickr wrote:
When you fire an event from the TableModel you are just notifying the table that data has changed so the table can repaint itself.
So unless you have some code based on that event, nothing abnormal should happen, other than the table repainting itself twice.
unfortunately that's not entirely true (or maybe you have a different notion of "abnormal" than me ;-)
- in all versions: the selection gets corrupted.
- since 1.6: throws an ArrayIndexOutOfBounds on sorting
As a very general, very basic rule: never-ever fire bogus events - there's always at least one listener which gets confused. This rule applies especially to events which notify about a structural change (like inserts, deletes). Code which does is broken and must be fixed asap. Plus, the only collaborator to call fireXX should be the model itself, consequently the scope of any fire methods should be narrowed to at least protected (not possible for those core classes with public methods - which was a design accident ;-)
Attached is a small example (which should have come with your question, javapunt, hint, hint ...) to show the side-effects
HTH
Jeanette
* Created on 25.06.2008
package org.jdesktop.swingx.table;
import java.awt.event.ActionEvent;
import java.util.Locale;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
public class FireBogeyInsert {
    private JComponent createContent() {
        JComponent content = Box.createVerticalBox();
        final Locale[] locales = Locale.getAvailableLocales();
        final AbstractTableModel model = new AbstractTableModel() {
            @Override
            public int getColumnCount() {
                return 3;
            @Override
            public int getRowCount() {
                return locales.length;
            @Override
            public Object getValueAt(int rowIndex, int columnIndex) {
                switch (columnIndex) {
                case 0:
                    return locales[rowIndex].getDisplayName();
                case 1:
                    return locales[rowIndex].getDisplayLanguage();
                case 2:
                    return locales[rowIndex].getDisplayCountry();
                return null;
        Action fireInsert = new AbstractAction("fire bogey insert") {
            @Override
            public void actionPerformed(ActionEvent e) {
                model.fireTableRowsInserted(0, 0);
        JTable table = new JTable(model);
        table.setAutoCreateRowSorter(true);
        table.setRowSelectionInterval(0, 0);
        content.add(new JScrollPane(table));
        content.add(new JButton(fireInsert));
        return content;
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame frame = new JFrame("");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.add(new FireBogeyInsert().createContent());
                frame.setLocationRelativeTo(null);
                frame.pack();
                frame.setVisible(true);
}

Similar Messages

  • How do you set the number of rows in a spreadsheet, so that even when you drag data in, in writes over those rows instead of adding a new row?

    How do you set the number of rows you want in a spreadsheet, so that even when you drag data in, in writes over those rows instead of adding a new row?

    After the discovery reported above, I filed this report :
    Bug ID# 10073038
    Summary:
    When Numbers is used on a system with decimal comma a csv file may be good AND wrong
    Steps to Reproduce:
    With Numbers v2, you introduced an interesting enhancement.
    In system using the comma as decimal separator, Numbers requires csv files using the semi-colon as values delimiter.
    In fact it’s true if we OPEN the document dragging its icon on Numbers one or thru the open dialog.
    This said.
    (1) Drag and drop a csv built with the 'semi-colon' standard on a table or on a sheet
    (2) Drag and drop a csv built with the 'comma' standard on a table or on a sheet
    Expected Results:
    Every normally constituted user assume that in
    case (1) he will get a perfectly built table
    case (2) he will get every cells of a row in a single cell
    Actual Results:
    In fact you forgot the drag and drop way of use and in
    case (1) every values separated by semi-colon are inserted in a single cell
    case (2) values separated by comma are correctly spread in a table
    isn’t it ridiculous ?
    Regression:
    Except looking in  QuickView to see which is exactly the structure of the file to decide the way we will insert it in a Numbers document, we may use an applescript fair enough to replace the semi-colons by TAB characters
    or
    to replace the commas by TABs and the decimal periods by commas
    Notes:
    While I am on this subject, I wish to make two proposals:
    (1)  It would be fine to format the date according to the ISO format year-mm-dd when you export a Numbers doc to csv.
    Doing that, dates would be imported correctly in every countries.
    At this time, on an English system, you export as mm/dd/year.
    If the doc is open on a system using the format dd/mm/year, the results will be odd.
    On a system using the format dd/mm/year, you export this way and so, if the doc is open on a system using the format mm/dd/year the results are odd too.
    As every localized versions accept the ISO format (at least on entry), using it in the export scheme would give a correct behavior everywhere.
    (2) It would be fine to add the format Tab Separated Values in the Export pane.
    TSV + ISO date format would give documents opening flawlessly everywhere.
    Yvan KOENIG (VALLAURIS, France) dimanche 4 septembre 2011 21:27:41
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • Problem while adding a new row to the table.

    hello,
    In my ADF form i have a table. and when i click on CreateInsert it add a new to the table but at the first. i want all the new rows to be added at the end of the table in a sequence. how can i do this?....
    Thanks and Regards,
    Rakshitha

    Hi,
    Try this:
    DCIteratorBinding dciter;
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
    dciter = (DCIteratorBinding) bindings.get("findAllTestAndryIter");
    ViewObjectImpl vo = dciter.getViewObject();
    if (vo != null)
    Row row = vo.createRow();
    int rangeSize = vo.getRangeSize();
    int rowsInRange = vo.getAllRowsInRange().length;
    int insertPos = rowsInRange < rangeSize? rowsInRange: rangeSize - 1;
    vo.insertRowAtRangeIndex(insertPos, row);
    vo.setCurrentRow(row);
    }

  • Problem with adding a new row in JTable

    Hi,
    I've created a JTable using DefaultTableModel with DefaultTableModel(Object[][] obj,Object[] col) constructor.I've written actionListener for a JButton which should add new row to the tablemodel.Now, the listener adds the row to the model.But its throwing an ArrayOutofBoundsException and the added row is not visible unless I click on any column of the table.
    Kindly help me to resolve this problem
    TIA
    Regards
    Gopi

    Thanks a lot for the reply. Here is the complete code
    TableImpl.java
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.table.*;
    import java.util.Vector;
    public class TableImpl extends JFrame {
    DefaultTableModel dataModel;     // TableModel Variable
    /* Constructor to add table and button to the frame     */
    TableImpl() {
              getContentPane().setLayout(null);
              setSize(800,600);
              myModel();
              final JTable table = new JTable(dataModel);
              JScrollPane scrollpane = new JScrollPane(table);
              getContentPane().add(scrollpane);
              scrollpane.setBounds(10,10,700,300);
              TableColumn tcCol = table.getColumnModel().getColumn(1);
              /* Adding ComboBox to the CellEditor of Column 2 of table     */
              JComboBox jcbComboBox = new JComboBox();
              final ReturnVector vctDBAccess = new ReturnVector();
              jcbComboBox.addItem(vctDBAccess.vctGetOidList().elementAt(0).toString());
              jcbComboBox.addItem(vctDBAccess.vctGetOidList().elementAt(2).toString());
              jcbComboBox.addItem(vctDBAccess.vctGetOidList().elementAt(4).toString());
              tcCol.setCellEditor(new DefaultCellEditor(jcbComboBox));
              /*     Adding Listener for Table      */
              dataModel.addTableModelListener(new TableModelListener() {
                   public void tableChanged(TableModelEvent e) {
              /* Columns Manipulation */
                        if(dataModel.getColumnName(e.getColumn()).equals("Second")) {
                        int iRow = e.getFirstRow();
                        int iColumn = e.getColumn();
                        String strColName = dataModel.getColumnName(iColumn);
                        String strData = (String)dataModel.getValueAt(iRow,iColumn);
                        String strNextColumn = dataModel.getColumnName(iColumn+1);
                        dataModel.setValueAt(vctDBAccess.vctGetOidList().elementAt(vctDBAccess.iGetIndex(strData)+1),iRow,iColumn+1);
              /* Adding button to Frame     */
              JButton jbInsert = new JButton("Insert");
              /* Adding new row to the Tablemodel -- Probelm is here     */
              jbInsert.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e){
                        try {
                   Object[] nrow = {"what", "ever", "you"};
                   dataModel.addRow(nrow);
                   }catch(Exception ex) {
                   System.out.println("Exception at adding row = " + ex);
    getContentPane().add(jbInsert);
    jbInsert.setBounds(100,350,100,20);
    addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) {
                   System.exit(0);
         /* Method to initialise new tablemodel     */
         public void myModel() {
              Object[][] data = { {new Integer(10),"two","three"},
                                                 {new Integer(5),"two","three"},
                                                 {new Integer(4),"two","three"},
              String[] col = { "First", "Second", "Third"};
              dataModel = new DefaultTableModel(data,col);
    public static void main(String arg[]) {
              TableImpl ct = new TableImpl();
              ct.setVisible(true);
    /* Class that returns a Vector of String for populating ComboBox entries and
              for getting the index of a particular element of the vector          */
    class ReturnVector {
                   Vector vctOidName=null;
                   ReturnVector() {
                        this.vctOidName = new Vector();
                        vAddOidList();
                   public void vAddOidList() {
                        String[] dbResult = {      "system", "1.3.6.1.2.1.1" ,
                                                      "interface", "1.3.6.1.2.1.2" ,
                                                      "snmp", "1.3.6.1.2.1.3" };
                        for(int i=0;i<dbResult.length;i++) {
                             System.out.println("Value = " + dbResult);
                             vctOidName.addElement(dbResult[i]);
                   public Vector vctGetOidList() {
                        return vctOidName;
                   public int iGetIndex(String strData) {
                        System.out.println("Index = " + vctOidName.indexOf(strData));
                        return vctOidName.indexOf(strData);

  • Problems with adding a new row in my table

    Im an ADF beginner but I thought it would be simple to to do some basic CRUD stuff in ADF. Im now even struggling when i try to add a new row to my table.
    Seems that the primary key id is not set correctly...
    could someone help?

    Hi,
    Have a look to this page CREATE SEQUENCE
    Regards,
    Sébastien
    Creating a Sequence: Example
    The following statement creates the sequence customers_seq in the sample schema oe. This sequence could be used to provide customer ID numbers when rows are added to the customers table.
    CREATE SEQUENCE customers_seq START WITH     1000 INCREMENT BY   1 NOCACHE NOCYCLE;

  • Problem in adding a new row in a table.. plsss hlppp

    Hi Friends,
    I have a table defaulted to 4 rows. I have a add button to add a new row in the table.
    When i have already 4 rows in table, and when i click add its adding that 5th row correctly( and i used set_lead_selection for this new row ).
    But i want to automatically make a next page once i hit the ADD button here. Each time now i m hitting next page then only  able to see hte 5th row. I need once ADD is clicked, i want to see the 5th row visible..
    Can someone tell me how to code or do this
    thanks friends,,,
    Niraja

    hi niraja,
    Plz refer to the following code:
    method onactiononadd .
    node_material type ref to if_wd_context_node.
    elem_material type ref to if_wd_context_element.
    stru_material type sflight.
    node_material =  wd_context->get_child_node( name = 'ANNA' ).
    elem_material = node_material->get_element(  ).
    if ( elem_material is initial ).
    call method node_material->create_element
    receiving
    element = elem_material.
    endif.
    call method elem_material->get_static_attributes
    importing
    static_attributes = stru_material .
    call method node_material->bind_structure
    exporting
    new_item = stru_material
    set_initial_elements = abap_false.
    endmethod.
    i hope it helps
    regards
    arjun

  • 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

  • Create a new row in a table without using add new row button

    I want to add a new row to the table without using the add new row button of the table. I'm not able to display default row in the table. Though if click on apply the record appears after saving in the database. Any thoughts how to implement this functionality.

    Here is what you have to do.
    1) You have to handle this in processRequest()
    2) In the AM code , u need to check if there is already a row exisit or vo is blank
    if (vo.getFetchedRowCount() == 0)
    // first time
    vo.setMaxFetchSize(0); // THIS IS REQUIRED.
    Row row = vo.createRow();
    vo.insertRow(row);
    row.setNewRowState(Row.STATUS_INITIALIZED);
    else
    //If already rows are there then you suppose to insert in the end
    // i assume you would have execute your vo
    YourVORowImpl row= (YourVORowImpl)vo.getRowAtRangeIndex(0);
    vo2.insertRowAtRangeIndex();
    It should work.

  • Adding a new row in the end!... Urgent...

    Hi,
    I have a requirement where i have a classic table with some of it's columns having default values. While using "Add Another Row", since these default values were not getting set, I used setAutoInsertion(false) on the tablebean, and used createRow and insertRow for adding new rows, but this new row gets added before my existing row. How to make it add after my existing row? I tried using vo.last()
    as suggested in some of the posts, but to no use.
    Thanks in Advance

    It is the framework behavior that when you add another row, the row is added as the last row in the current range. The existing last row in the current range is pushed into the next range.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                               

  • Dynamically adding a new row to a JTable

    Have anybody tried to add a new row to JTable? In the JTable if the user is editing the last row, another row should be created and displayed dynamically, without loosing the contents in the other rows and without any flickering effect. Is this possible in java applications or applets?
    -Madhuri.

    again, do all yoru work in the table model. make a class that implements the table model interface. if you mail me I can send you a table model I made(I have about 8) and you will see what to do from that. Its all about the table Model, not the table.
    Try using ArrayList instead of Vector unless you need it to be thread safe.

  • How to move an object with its animation path, without adding a new keyframe?

    Hi,
    If I create an object which has a keyframe animation, how can I change its location/scale without adding new keyframes? That is, I want to move the whole thing with all its animations & keyframes as a single entity.
    thanks
    Arun

    Hi,
    big thanks for that. Unless Im doing something stupid when I did that it made a new copy of the object but did allow me to place that new instance elsewhere.
    Is there any way just to move an object and its path without making a new copy?
    All the best
    Arun

  • How to set a default value in an ADF table when adding a new row

    Hi Guys,
    I have a view object which I am using to create an ADF table. I also have a button which uses a CreateInsert binding to add a new row to the table. I have four fields: created_by, creation_date, last_update_by and last_update_date.
    I want these values to be set automatically when I click add new row.
    The values I want are:
    created_by - admin
    creation_date - sysdate
    last_update_by - admin
    lsat_update_date - sysdate
    Any suggestions on how to do this would be appreciated
    Thanks
    -Mark

    mark,
    Those four fields can be set completely declaratively in the Entity Object (check out the History Colum feature). Copied from the (11g) documentation:
    If you need to keep track of historical information in your entity object, such as when an entity was created or modified and by whom, or the number of times the entity has been modified, you specify an attribute with the History Column option selected (in the Edit Attribute dialog).
    If an attribute's data type is Number, String, or Date, and if it is not part of the primary key, then you can enable this property to have your entity automatically maintain the attribute's value for historical auditing. How the framework handles the attribute depends which type of history attribute you indicate:
    * Created On: This attribute is populated with the time stamp of when the row was created. The time stamp is obtained from the database.
    * Created By: The attribute is populated with the name of the user who created the row. The user name is obtained using the getUserPrincipalName() method on the Session object.
    * Modified On: This attribute is populated with the time stamp whenever the row is updated/created.
    * Modified By: This attribute is populated with the name of the user who creates or updates the row.
    * Version Number: This attribute is populated with a long value that is incremented whenever a row is created or updated.
    John

  • Adding a new row to database and then modify it

    Hi there,
    Im pretty sure this is a simple matter but i am new to JDBC,
    i have an application where i create a new member in a database and then want to modify part of that members info (weather he pays for something monthly or annually)
    I can add the new member easily, and I create a unique ID and place him in the db.unigue ID assigned by Access db.
    Then i want to bring the same member back and alter his data, since I am inserting new data there is no resultsSet returned (am i right about this?)
    so how can I get the same member back and alter his data, or at least find out what his ID was so i can do a query for the same ID?
    cheers
    D

    because you talk about creating new row then I assume you know how to invoke the executeUpdate() method. You can change the field in your table with the UPDATE command. The sintaxt of UPDATE following your database system sintaxt. If you want to query the data in the table you can use the method excuteQuery(). i.e. executeQuery("SELECT * from tableName").

  • Adding a new row programatically

    I have the following use case :
    1) I have a jsf page having adf table which displays all the records from the employees table of hr schema.
    2) pagination was implemented on this table and this table contains two buttons "Add New Row" and "Save".These buttons will be displayed in every page.
    3) when the "Add New Row" is clicked,a new row has to be inserted as the last record of adf table in jsf page.
    i.e suppose if the employees table contains 45 records,the adf table in my .jspx page displays 5 pages(each page contains 10 records).If i click "Add new row" button in page 2,the new record should be inserted as the 46th record in the 5 th page and the control should transfer to 5th page to enter the values for the new row.
    4)After entering the values and save button is clicked,all the values of newly inserted rows should be inserted into the database.
    How to acheive this functionality.
    I did the following :
    1)created the entity and view objects.
    2)written a bussiness method in AMImpl to insert a new row when the 'Add new row" button is clicked.But this method is inserting the new row as the last record in the same page that I performed the operation.
    Below is my code snippet :
    public void addNewRow(){
    Row newRow=getEmployeeObj().createRow();
    newRow.setNewRowState(Row.STATUS_INITIALIZED);
    EmployeeUVOImpl vo = (EmployeeUVOImpl)getEmployeeObj();
    int res=vo.getFetchedRowCount()/vo.getRangeSize();
    int remin=vo.getFetchedRowCount()%vo.getRangeSize();
    if((vo.getFetchedRowCount()%vo.getRangeSize())>0){
    vo.insertRowAtRangeIndex(vo.getRangeSize(),newRow);
    else{
    vo.insertRowAtRangeIndex(vo.getRangeSize()-1,newRow);
    Thanks in Advance,
    Regards,
    Siva

    Hi,
    the code below works in JDeveloper 11g. However, it works similar for 10.1.3 so you may want to have a look
        public String newRowAction() {
            CollectionModel tableModel = (CollectionModel) table1.getValue();
            JUCtrlHierBinding adfModel = (JUCtrlHierBinding) tableModel.getWrappedData();
            DCIteratorBinding dciter = adfModel.getDCIteratorBinding();
            Row lastRow = dciter.getNavigatableRowIterator().last();
            Row newRow  =  dciter.getNavigatableRowIterator().createRow();
            newRow.setNewRowState(Row.STATUS_INITIALIZED);
            int lastRowIndex = dciter.getNavigatableRowIterator().getRangeIndexOf(lastRow);
            dciter.getNavigatableRowIterator().insertRowAtRangeIndex(lastRowIndex+1, newRow);
            dciter.setCurrentRowWithKey(newRow.getKey().toStringFormat(true));
            //table should have its displayRow attribute set to "selected"
            AdfFacesContext.getCurrentInstance().addPartialTarget(table1);
            return null;
        }Frank

  • Adding a New row in Workbook above Table values

    Hi,
    I have created a Workbook for which i need to add 2 additional rows manually at the top.  I added a row by deleting the Blue color line (with word 'Table').  But when i refresh the workbook, the blue color line is appearing again and the row which i added disappeared. 
    How do i make this possible?  Is there any way through which i can add the lines just above the Table values?
    Any help on this will highly be appreciated.
    Regards,
    Murali

    Hi,
    As per my view , Table name was written in the Backend with VB script hence its require change that first later you can include the Additinal rows .
    Regards,
    satya

Maybe you are looking for

  • How can I change the style of a google map in Adobe Muse?

    I have seen some nice changes of google maps out there. This tool helps you to customize your maps. http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html When I want to integrate a google map I copy in something like this: <if

  • Itunes do not syncronize all photos from iphoto

    Hi, I have some problems in syncronizing photos through iTunes with my iPad 2. I select some events from the Photo menu, but not all the photos within are syncronized. I already tried to delete the iPod Photo Cache folder, no success. Using iPad 2 iO

  • How to hide column in BEx Analyzer

    Hi gurus In my report I have to show 5 columns depending on a condition. Is it feasible? Regards

  • Working with converted .mov files in Premiere Elements 2

    I recently got a digital camera that records .mov clips with H.264 technology. I use it for back up when Im having problems with my regular camcorder. Of course I can work with these .mov files in QuickTime Pro with no problem. But in order to work w

  • Identifying changes in the custom screen added to Delivery

    Hello, I have added a custom screen in delivery transaction(VL02n) at header level. I used BADI LE_SHP_TAB_CUST_HEAD to do that. Now if user comes and enters some data on the custom screen, then goes to menu option Subsequent processing-->Create Tran