0

zk calendar onEventCreate doesn't work notifyChange

asked 2017-09-28 00:39:18 +0800

ajamardo gravatar image ajamardo
21 2

updated 2017-09-28 10:25:52 +0800

cor3000 gravatar image cor3000
3484 1 7
ZK Team

NotifyChange doesn't work in onEventCreate of the zk calendar. I tried the code as a command triggered by a button and it worked, but with the calendar oncreate it doesn't.

    private boolean showInsertNewActivity=false;

    public boolean isShowInsertNewActivity() {
        return showInsertNewActivity;
    }
    public void setShowInsertNewActivity(boolean showInsertNewActivity) {
        this.showInsertNewActivity = showInsertNewActivity;
    }
    @NotifyChange({"simpleCalendarModel","showInsertNewActivity", "activitySession"})
    public void onEventCreate(CalendarsEvent event) {
        setShowInsertNewActivity(true);
        //System.out.println(event.toString());
    }


<if test="@load(vmApp.showInsertNewActivity)">
    Some Code
</if>
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-09-28 10:48:34 +0800

cor3000 gravatar image cor3000
3484 1 7
ZK Team

updated 2017-09-28 10:49:55 +0800

the @NotifyChange annotation only works in combination with @Command.

In your case you should try something like this in your zul file:

<calendars model="@load(vm.simpleCalendarModel)" 
           onEventCreate="@command('insertNewActivity')" ... />

in your ViewModel:

@Command
@NotifyChange({/*"simpleCalendarModel",*/"showInsertNewActivity", "activitySession"})
public void insertNewActivity(@ContextParam(ContextType.TRIGGER_EVENT) CalendarsEvent event) {
    setShowInsertNewActivity(true);
    //System.out.println(event.toString());
}

I commented out "simpleCalendarModel" from the notify list. It should not be necessary to notify-change the whole SimpleCalendarModel. Updates within the model (adding/removing events) will update the UI automatically because the Calendar component listens to data changes triggered within the CalendarModel (if not please post a bug with steps to reproduce the issue).

Only if you create a new instance and assign it to simpleCalendarModel you have to notify-change the variable.

Robert

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
2 followers

RSS

Stats

Asked: 2017-09-28 00:39:18 +0800

Seen: 5 times

Last updated: Sep 28