1

problem with @NotifyChange

asked 2014-01-27 15:40:30 +0800

demizon gravatar image demizon
169 1 6

Hi, i got method which delete item from list. In 1st case, without Messagebox everything works perfectly...

@Command
    @NotifyChange ({"relaisList"})
    public void deleteRelay(@BindingParam("relay") SicherungenRelais9X1Wrm myRelay)
    {
        sicherungenRelais9X1WrmManager.delete(relayToDelete);
        relaisList=sicherungenRelais9X1WrmManager.getAll();        
    }

In the second one (with Messagebox to confirm item deletion) item is deleted from my DB, but itemlist is not updated...

@Command
    @NotifyChange ({"relaisList"})
    public void deleteRelay(@BindingParam("relay") SicherungenRelais9X1Wrm myRelay)
    {
        relayToDelete=myRelay;
        Messagebox.show("Are you sure?", "Delete?", Messagebox.YES|Messagebox.NO,
                Messagebox.QUESTION,
                new EventListener() {
                    public void onEvent(Event evt) {
                        if ("onYes".equals(evt.getName())) {                       
                        sicherungenRelais9X1WrmManager.delete(relayToDelete);
                        relaisList=sicherungenRelais9X1WrmManager.getAll();
                         }
                    }
                }
        );
    }

Thx in advance for help.

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
5

answered 2014-01-27 16:43:35 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

updated 2014-01-27 16:44:42 +0800

you try it:

    @NotifyChange ({"relaisList"})
     @Command
    public void deleteRelay(@BindingParam("relay") SicherungenRelais9X1Wrm myRelay)
    {
        relayToDelete=myRelay;
        Messagebox.show("Are you sure?", "Delete?", Messagebox.YES|Messagebox.NO,
                Messagebox.QUESTION,
                new EventListener() {
                    public void onEvent(Event evt) {
                        if ("onYes".equals(evt.getName())) {                       
                        sicherungenRelais9X1WrmManager.delete(relayToDelete);
                        relaisList=sicherungenRelais9X1WrmManager.getAll();
                       BindUtils.postNotifyChange(null, null, ViewModelClass.this, "relaisList");// here notify your list
                         }
                    }
                }
        );
    }
link publish delete flag offensive edit

Comments

it works, thank you!

demizon ( 2014-01-28 07:09:38 +0800 )edit
0

answered 2014-01-27 16:39:54 +0800

roliroli gravatar image roliroli
164 4

How about

@Command
@NotifyChange ({"relaisList"})
public void deleteRelay(@BindingParam("relay") SicherungenRelais9X1Wrm myRelay)
{
    relayToDelete=myRelay;
    int result = Messagebox.show("Are you sure?", "Delete?", Messagebox.YES|Messagebox.NO,
            Messagebox.QUESTION,
            new EventListener() {
                public void onEvent(Event evt) {
                    if ("onYes".equals(evt.getName())) {                       
                    sicherungenRelais9X1WrmManager.delete(relayToDelete);
                     }
                }
            }
    );
    // Only update UI when delete
    if(result == Messagebox.YES) {
       relaisList=sicherungenRelais9X1WrmManager.getAll();
    }
}

There are a thread talking about the same issue and they have another workaround approach with global command

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-01-27 15:40:30 +0800

Seen: 30 times

Last updated: Jan 27 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More