Results 1 to 4 of 4

Thread: Delete Button

  1. #1
    Zoroxeus is offline Member
    Join Date
    Oct 2008
    Posts
    1
    Rep Power
    0

    Default Delete Button

    Hi I have added a delete button to my table
    the goal is that when i click on it, it deletes the row
    my buttonTableDelete_action() is as follow:

    Java Code:
    RowKey[] selectedRowKeys = getTableRowGroup2().getRowKeys();
                Users[] users = getSessionBean1().getUsers();
                int rowId = Integer.parseInt(selectedRowKeys[0].getRowId());
                Users user = users[rowId];
                // Remove the Entity from the database using UserController
                UserController userController = new UserController();
                userController.removeUser(user);
    But this does not work... it deletes instead the first row on the column...
    any idea why ?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default

    Last edited by DarrylBurke; 10-22-2008 at 08:41 PM.

  3. #3
    varun is offline Member
    Join Date
    Oct 2008
    Posts
    1
    Rep Power
    0

    Default

    Hello Zoro,

    Please confirm yourself whether selectedRowKeys fetching only the selected row key or all the row keys in the datatable,

    If it fetches all the row keys in the datatable then it always deletes the first row only,
    because in the following line code
    int rowId = Integer.parseInt(selectedRowKeys[0].getRowId());

    you have hardcoded "0" and always getting the first rowkey as selectedRowKeys[0] returns the first object.
    Please let me know if that works fine or not

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Delete
    By Sarinam in forum New To Java
    Replies: 6
    Last Post: 07-23-2008, 12:09 PM
  2. Delete From .txt file
    By Sarinam in forum New To Java
    Replies: 86
    Last Post: 06-28-2008, 11:17 AM
  3. delete string in JtextArea
    By cloudet in forum AWT / Swing
    Replies: 3
    Last Post: 05-05-2008, 11:06 AM
  4. Listbox Add/Delete
    By Rageagainst20 in forum New To Java
    Replies: 2
    Last Post: 04-16-2008, 05:49 PM
  5. How to delete a file
    By Alpha in forum New To Java
    Replies: 1
    Last Post: 05-26-2007, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •