-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a menu and a main working area. When someone clicks on the menu, I create a window from ZUL file and place it into the main area. But along to that I cache this component:
Map<String, Component> mainAreaWindowsCache
Thanks for the reply. This doesn't help though :) What you suggested is to trigger all @NotifyChange in the this VM, right? Let me give you more details: the problem itself is that I have 2 VMs. One is the VM of the WholeArea that listens to the menu pressing, and the VM of the working area. When I attach the WorkingArea component back to the WholeArea, it doesn't recognizes that there is this WorkingAreaVm, it only sees WholeAreaVm and tries to trigger @commands on it.
This schema works if instead of caching the WorkingArea components I create them from scratch every time, but I'd like to cache them..
PS: if it's possible, could you point out what is the object graph/relationships and the lifecicle in scope of Bindings and ViewModels.
Hi ctapobep,
Do you mean you have a WorkingAreaVm inside a WholeAreaVm ?
Currently I will suggest you provide a 'getter' in WholeAreaVm ,
and use command in WholeAreaVm to trigger the real method in WorkingAreaVm .
In zul page, there is something like '@command('doSomethingOfWorkingArea')' that trigger the method in WholeAreaVm ,
in WholeAreaVm, has a method and a getter below:
@NotifyChange('workingVM') public void doSomethingOfWorkingArea () { workingAreaVM.doSomething(); } public WorkingAreaVM getWorkingVM () { if (WorkingAreaVM == null) initWorkingVm(); return WorkingAreaVM; }
i.e., everything handled by the WholeAreaVm,
and trigger the method of WorkingAreaVM or update WorkingAreaVM by it.
Regards,
ben
Well, this version would clutter the main VM, thus I made it differently :) The WholeArea is a window and it has a viewModel defined that gets the VM from Spring context. The WorkingArea is also a window inside WholeAreaWindow and it also has viewModel which it can also acquire from Spring Context. Thus these two VMs are totally decoupled, they don't know about each other. The WholeAreaVm just creates a window which grabs its VM on its own.
I am facing now the same problem.
Anyone?
/costas
Asked: 2012-02-25 21:27:40 +0800
Seen: 214 times
Last updated: Jan 08 '13