0

Why does the order of NotifyChange may alter the result of the objects?

asked 2017-10-12 16:52:30 +0800

ajamardo gravatar image ajamardo
21 2

I have this code:

@GlobalCommand
@NotifyChange({  "showAddParticipantsSiteModal", "showAddSiteModal", "activitySession", "newParticipant"})
public void addSite(@BindingParam("type") String type, @BindingParam("site") ActivitySite site){
    if (type.equals("participant")){
        setShowAddParticipantsSiteModal(false);
        getNewParticipant().setSite(site);
    } else if (type.equals("activitySite")){
        setShowAddSiteModal(false);
        getActivitySession().setSite(site);
    }
}

And it works, BUT, changing the order in the notifyChange variables to:

@GlobalCommand
@NotifyChange({ "activitySession", "newParticipant", "showAddParticipantsSiteModal", "showAddSiteModal"})
public void addSite(@BindingParam("type") String type, @BindingParam("site") ActivitySite site){
    if (type.equals("participant")){
        setShowAddParticipantsSiteModal(false);
        getNewParticipant().setSite(site);
    } else if (type.equals("activitySite")){
        setShowAddSiteModal(false);
        getActivitySession().setSite(site);
    }
}

The values of the sites are not updated, the setSite 'does not do its job'. What's the reason for that? Note that the modals are the ones sending the new site to the global command.

Thanks in advance.

delete flag offensive retag edit

Comments

are all your getters normal getters or do they have logic behind?

chillworld ( 2017-10-12 17:49:43 +0800 )edit

Yes, they have no logic inside. In fact I also tried to set the whole object with setActivitySession() and it doesn't work either.

ajamardo ( 2017-10-12 18:11:52 +0800 )edit

If it was me, I should check if there was no error thrown (but maybe catched an not logged) so the chain is broken. Normally the order doesn't have any impact because it's triggered after your method. But be aware for @DependsOn, that could trigger also.

chillworld ( 2017-10-12 18:34:03 +0800 )edit
Be the first one to answer this question!
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: 2017-10-12 16:52:30 +0800

Seen: 6 times

Last updated: Oct 12