How to avoid editing a deleted record in a Table component

Hi! Everyon,
I am building a prototype using JSC. In Page1.jsp, I have a table displaying the records. On column one there are buttons that allow the user to edit the record, including deleting it. My problem is: when somebody else deleted a record and if the current user tries to edit the same record by clicking the edit button on the corresponding row he will get the next record. Could somebody tell me how to solve this problem? Thanks in advance.
By the way, I do not access database directly from the Web part. Instead, I dropped a session bean's method on the Table compoment. In the edit button's event handler, I use
           TableRowDataProvider row = (TableRowDataProvider )getBean("currentRow");However, since that record was deleted already I always get the next record.
With best regards,
Daniel

Thank you very much for your help. And sorry for not explaining clearly.
I have a session bean that has getCities(), getCity(String code) and other methods. getCities() returns an array of CityDO objects and getCity(String) returns a CityDO object. class CityDO basically is a JavaBean containing city code, city name and other information. When I designed the web part using Java Studio Creator, I dropped a Table component to the design view first, then dropped the EJB method getCities() onto that Table component. Up to now, it is very similar to http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/ejb.html and everything worked fine.
In order to edit a CityDO record, I added a column containg "edit" buttons into the Table component. If the user clicks the edit button we will show the CityDO in another page called editPage.jsp. In editPage.jsp, the user can update the city or simply delete it. Here is the major part of the event handler of the edit button in Page1,
    public String editCity_action() {
        TableRowDataProvider row = (TableRowDataProvider)getBean("currentRow");
        String code = (String)row.getValue("code");     // "code" is a field in CityDO
        CityDO city = null;
        try {
            city = cityClient1.getCity(code);
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        getSessionBean1().setCity(city);          // pass the city to editPage
        return "editPage";
    }Usually, the above logic is good. However, if somebody else deleted one city and the current user tries to edit that deleted city (it is still in his table), he gets the next city. The real problem is in editCity_action(),
row.getValue("code") returns an updated value, but I only need the old one.
You memtioned ArrayList. That could be a good solution. Suppose I have an ArryList containing the CityDO objects, if I can bind the table to my ArrayList that will solve my problem. Could you tell me how to do the binding in that case?
Thank you again.
With best regards,
Daniel
By the way, I do not access database directly from
the Web part. I do not understand what you mean by the above
statement.
Instead, I dropped a session bean's
method on the Table compoment. Can you explain further. What method did you drop on
the Table component?
In the edit button's
event handler, I use
TableRowDataProvider row =
(TableRowDataProvider
)getBean("currentRow");However, since that
record was deleted already I always get the next
record.Here is the delete code from
http://developers.sun.com/prodtech/javatools/jscreator
/learning/tutorials/2/inserts_updates_deletes.html.
As is is working on the rowkey in the page bean's
table, that should not be affected by other users in
other sessions, the rowkey should not change, even if
the underlying record has changed.
    public String delete_action() {
form1.discardSubmittedValues("save");
try {
RowKey rk = tableRowGroup1.getRowKey();
if (rk != null) {
tripDataProvider.removeRow(rk);
tripDataProvider.commitChanges();
tripDataProvider.refresh();}
(Exception ex) {
log("ErrorDescription", ex);
error(ex.getMessage());
return null;
}What is the underlying structure for the table's
data. Is it a row cache from a query? Is it an
ArrayList?

Similar Messages

  • How to avoid displaying a blank row in the table component

    Hi,
    I have a create insert button and a table as in a read only form.
    Each time i click on a create insert button a popup appears were the person enter the corresponding values and on clicking submit button it has to show changes in the table and on clicking cancel button it has to go back to the page.
    But even when i click the cancel there is still an empty row is shown in the table. Is there a way to avoid it ?
    Thanks in advance.

    I am using this managed bean to refresh the table.
    public class popupRefreshBean
    private RichTable refreshTable;
    public popupRefreshBean()
    public void refreshTable(ReturnEvent returnEvent)
    AdfFacesContext adf=AdfFacesContext.getCurrentInstance();
    adf.addPartialTarget(this.getRefreshTable());
    // Add event code here...
    public void setRefreshTable(RichTable refreshTable)
    this.refreshTable = refreshTable;
    public RichTable getRefreshTable()
    return refreshTable;
    }

  • Hello, How can I edit or delete a custom label in the contacts list on iOS 7.0.3 on iPhone 4S ?

    Hello, How can I edit or delete a custom label in the contacts list on iOS 7.0.3 on iPhone 4S ?
    i need it so muchhh!

    Sort of depend on what you are trying to do precisely. In Edit mode, if you tap on any label, you will be given a list of options, plus an Add Custom Label option near the bottom of the list

  • How can I edit or delete a custom label in the contacts list on iOS 7 on iPhone 4S ?

    How can I edit or delete a custom label in the contacts list on iOS 7 on iPhone 4S ?

    Alfre311 wrote:
    I've been trying to find a way to do this since I updated to IOS 7, and I've just found the solution/explanation, even tho is a bit heavy to carry out.
    IOS 6 creates custom labels and save them giving you the option to delete them.
    IOS 7 creates custom labels but don't save them, so there is no need to have the option to delete them.
    But here comes the problem, if you have some custom labes saved in you Iphone / Ipad with IOS 6 and you update it to IOS 7, the device will keep those labels saved, but you wont be able to delete them.
    I realized this by going to contacts on Icloud. There those labels that I had on my devices weren't there. So simply restoring your device and configuring it as a new one to later sync your Icloud Contacts, will solve the problem.
    I know this post is old, but I might just try this with iOS 8. I have outdated custom labels that annoy me, because I still seem them in the list as options. If I get desperate enough, I may try your solution.

  • How can I edit and delete IOS 7 IPAD safari favorites?

    In IOS7/Ad safari, how can I edit or delete safari favorites?
    Thanks!
    Alan

    Thank you so much!   This solved my problem.
    I wish Apple made this sort of thing more accessible in its documentation somewhere.   I Google'd extensively but was unable to find anything relevant.
    Thanks much again!
    Alan
    P.S. -- I assume there's no way to delete multiple bookmarks/favorites simultaneously (I did it one at a time)...

  • How can i edit and delete contacts in mail on my macbook pro?

    how can i edit and delete contacts in mail on my macbook pro?

    Answer is in this Apple discussion thread.
    Hope it helps.
    https://discussions.apple.com/thread/3101891?start=0&tstart=0

  • I need to edit a re-occurring event in calender on my iPhone and there is no edit button for that event. How do I edit or delete it?

    I need to edit a re-occurring event in calender on my iPhone and there is no edit button for that event. How do I edit or delete it?

    I am not sure how this works but it seems that it may be all or nothing.
    To turn off Facebook events on your device:
    Settings > Facebook > Calendars > Off
    If you do not want to disable everything, maybe this thread will help:
    https://discussions.apple.com/thread/4349443

  • How do I edit or delete borders in a Contribute CS5 webpage?

    How do I edit or delete borders
    in a Contribute CS5 webpage?

    Can you please detail me on the request? For example, Table border or image border...

  • How can I edit or delete music from itunes match?

    How can I edit or delete music from itunes match?

    Hi,
    If you activate match on your new laptop, you will have access to all music that you matched or uploaded. You have the option to retain the music by downloading to your computer. If you delete music, it will delete from cloud.
    Jim

  • How to check deleted record in a table

    Hi to all,
    any one can do need ful to me for how to check last deleted record in a table.

    Since you are on 8i,
    AUDIT DELETE TABLE AUDIT
    and Using LogMiner
    are your best chance to find out last deleted records.
    If you are on 9i and later, you can also use flashback query to join current table with table image few minutes back to find out the difference.

  • As i am fresher Please share the doc of ECMA script using java script in SharePoint 2013 also how we can insert,update,delete records in list using ECMA script.

    As i am fresher Please share the doc of ECMA script using java script in SharePoint 2013 step by step also how we can insert,update,delete records in list using ECMA script.
    Thanks and Regards, Rangnath Mali

    Hi,
    According to your post, my understanding is that you want to use JavaScript to work with SharePoint list.
    To create list items, we can create a ListItemCreationInformation object, set its properties, and pass it as parameter to the addItem(parameters) function
    of the List object.
    To set list item properties, we can use a column indexer to make an assignment, and call the update() function so that changes will take effect when you callexecuteQueryAsync(succeededCallback,
    failedCallback). 
    And to delete a list item, call the deleteObject() function on the object. 
    There is an MSDN article about the details steps of this topic, you can have a look at it.
    How to: Create, Update, and Delete List Items Using JavaScript
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • TS3274 how do you edit and delete email contacts

    How do you edit and delete email contacts

    Go to that contact in your Contacts app and then tap the Edit button in the upper right and edit it.
    Make sure that in Settings>iCloud Contacts is turned ON.

  • Delete records from internal table

    hi all,
    i want to delete records from intenal table which are starting with a particular starting number .
    eg internal table
    10000
    20000
    90000
    91000
    92000
    88880
    i want delete the records starting with 9 i.e. 90000 91000 92000.
    Thanks in Adv
            RAJ

    You can test this piece of code.
    DATA:
    i_tab TYPE STANDARD TABLE OF mara,
    wa_tab TYPE mara.
    wa_tab-matnr = '1000'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1002'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1003'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '2001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '3001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '4010'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Aug 8, 2008 4:49 PM

  • Deleting Records from Referential Tables

    Hi,
    Can anyone help me in deleting records from tables in a hierarcial manner. For e.g C refers B and B refers A. I need to delete data from all three tables related to a where clause in A.I tried using User_constraints and User_cons_columns views. But i am not able to find a hierarchial delete statement.
    Venkatesh

    Did you look into the option of specifying ON DELETE CASCADE for your foreign key constraints. That way, if you delete a
    row from the master table Oracle will automatically go and delete the child rows. Take a look at the following script.
    Here, when I delete a row from table A for NUM = 1 the child rows from table B (WHERE num = 1) are automatically deleted.
    drop table b
    drop table a
    create table a (num number, name varchar2(40))
    create table b (num number, name varchar2(40))
    alter table a add constraint pk_a primary key(num)
    alter table b add constraint fk_b_num foreign key (num) references a(num) on delete cascade
    insert into a values (1, 'Test#1')
    insert into a values (2, 'Test#2')
    insert into b values (1, 'Referes#1')
    insert into b values (2, 'Referes#2')
    select * from a
    select * from b
    delete from a where num = 1
    select * from a
    select * from b
    Sridhar,
    Thanks a lot for your help.My exact need was to delete records in 50 tables starting with the key table for a specific condition in the key table.
    Assume table A has 100 records,B 200 records,C 150 records,D 400 records, etc
    When i want to delete some records in table A, i will not be able to do that as child records exists in table B and this structure will carry on till that last table in my application. How do i delete those specific records
    Venkatesh

  • How could I insert the deleted row into another table within a trigger?

    Hi,
    How could I insert the deleted row into another table within a trigger? The destination table has the same columns as the source table. Since the statements are in the trigger, it is not allowed to query the source table named 'test'. Thanks! The trigger is as follows, uncompleted:
    CREATE TRIGGER delete_trigger
    AFTER DELETE
    ON test
    FOR EACH ROW
    BEGIN
    -- How could I insert the deleted row into another table
    END delete_trigger;
    Message was edited by:
    user569548

    Hi,
    I'm not sure what's wrong there.
    I read the oracle docs about ANALYZE and ALL_TAB_COLUMNS, and did the following:
    ANALYZE TABLE my_tab VALIDATE STRUCTURE; //went ok.
    SELECT column_name
    FROM all_tab_columns
    WHERE table_name = 'my_tab'; //but no rows selected?
    This topic might not be what this thread should be about. Here I posted a new thread:
    How to get colum names of the newly created table?
    Thanks.
    Message was edited by:
    user569548

Maybe you are looking for

  • Problem using ipod with itunes 5.0.1

    Could anyone help me?? I'm having serious problems using my ipod mini with my "just downloaded" itunes 5.0.1. it says that my comunication software with ipod is not correctly installed and that i have to reinstall itunes again. i did it the problem i

  • Appending Objects in an internal Table

    Hallo Guru, I'm looking for a way to append newly created objects of a class "XYZ" in an internal table. Best Regards, Kais

  • 20" and 15" apple displays on 1-G4

    I want to run two monitors off my G4 MDD. I have a 20" ACD connected to the Machine and I have a 15" Apple Studio Display going to a DVI converter and then to my other monitor port on my G4. Ideally I want to mirror the 20" display for my clients to

  • Error on Business Complete

    Hi Gurus, Can you help me with my Business Completion error, a warning log says "Purchase Order item 902245 00010 of order 1000001 still without final billing indic." I've done settlement already and it did settle. This  was the first time i encounte

  • Insert Disc 1, Can't Reinstall Software

    Hello, Windows 7, Creative Suite Prodution Studio Premium, upgrade path. No viruses, was working fine, was just opening Audition, no software added recently. Tried restore points, no help. disabled virus protection. Many reboots. Tried everything. I