-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi
Just a have quick question.
Code 1:
@Command
public void onNextStep() {
if (this.currentStep.equalsIgnoreCase("step1")) {
doAfterStep1();
}
}
@NotifyChange({ "canPrevious", "steps" })
public void doAfterStep1() {
if (this.labOrder == null) {
Messagebox.show("Please select Patient and then continue",
"Select Patient", Messagebox.OK, Messagebox.INFORMATION);
return;
}
Messagebox.show("asdsad");
this.currentStep = "step2";
this.canPrevious = true;
this.steps = "Step : 2 Enter Patient Visit Information";
}
In the above, UI does not updated after doAfterStep1 is called. But when i change the code as follows
@Command
@NotifyChange({ "canPrevious", "steps" })
public void onNextStep() {
if (this.currentStep.equalsIgnoreCase("step1")) {
doAfterStep1();
}
}
public void doAfterStep1() {
if (this.labOrder == null) {
Messagebox.show("Please select Patient and then continue",
"Select Patient", Messagebox.OK, Messagebox.INFORMATION);
return;
}
Messagebox.show("asdsad");
this.currentStep = "step2";
this.canPrevious = true;
this.steps = "Step : 2 Enter Patient Visit Information";
}
Now it works. Why this behavior ?
as per my understanding @Command
annotation use for identify method from zul page and @NotifyChange
also notify when you call from zul page.
suppose you want notify doAfterStep1()
method without @NotifyChange
annotation
you can use
BindUtils.postNotifyChange(null, null, this, "*");
@NotifyChange works on setters too
e.g in ZUL
<checkbox label="Time Sensitive Only" checked="@bind(vm.unfedPatientFilterTimeSensitiveOnly)" />
In java code (VM)
@NotifyChange("unfedPatients")
public void setUnfedPatientFilterTimeSensitiveOnly(boolean unfedPatientFilterTimeSensitiveOnly) {
this.unfedPatientFilterTimeSensitiveOnly = unfedPatientFilterTimeSensitiveOnly;
initUnfedPatients();
}
Thanks AJaidka Paxcel Technologies
@Command :ViewModel's Command is like an event handler, we can bind an event to a Command. The binding between events and a command is what we call "Event-Command Binding". Before establish this binding, we have to declare a Command with its name in a ViewModel.
@NotifyChange("*"):To notify binder one or more properties change.
Yes. I've posted about this before. I really wish you could create "notify changes" on other methods that your command calls, but alas that is not the case. I assume the devs have some good reason for this?
It actually gets even more frustrating Senthilchettyin when you have a base class VM method that has a command and the base class command now delegates a call down to one of its implementing class methods. I didn't want to have constantly update the base class method command with every possible notify change that a subclass could use that happens to implement this Base VM (really breaks the OO paradigm there, especially if you're building a library.)
I wrote about the solution here http://www.learntechnology.net/2013/04/01/notify-change-from-base.html as was really provided to me Matze2
rickcr, Can you please give or write article in your site for implementing base class VM with command methods such as Add, Edit , delete and view ?
Senthilchettyin ( 2013-07-21 13:03:22 +0800 )editHi rickcr
Thank you very much. I learned some new stuff today :)
senthil
Asked: 2013-07-05 14:40:13 +0800
Seen: 280 times
Last updated: Jan 24 '14
Notify Form of property change
Databinding and auto-complete on combobox
Composite component and bind in ZK 6
How to detach / reattach MVVM windows?
Is there a way to resolve view model properties as input to client side javascripts?
How can I synchronize data in a ListBox in MVVM ? [closed]
MVVM Validator: class not found ? [closed]
How to Call Child ViewModel Method from Parent Window? [closed]