-
FEATURED COMPONENTS
First time here? Check out the FAQ!
For most of my zul pages I use mvvm. I declare a view model as follows
<window title="Contact List" border="normal"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.MyVM')" hflex="1" vflex="1" contentStyle="overflow:auto">
I just discovered that it appears possible for each ui component to have it's own ViewModel in a zul page.
I will like to ask
what are the usage scenarios for using more than one view model in a zul page ?
is it possible for two view models in the same page to pass data to each other ?
or at least can a parent view model supply a parameter to child view model ?
If this is possible how can I declare such functionality in a zul ?
My understanding is that the parent view model is the view model I bind to my window ui component then other view models that I bind to other ui's e.g. grid in the page are the child view models.
I would appreciate clarity on the above as it can open up many possibilities as to how I develop my application.
There are so many options and this it not just "clarified" in a simple post ... so I'd suggest to specify a few requirements first.
A common scenario is having a Navigation view model and separate viewmodels dedicated to individual pages.
And yes, it's possible to pass data between view models - e.g. using global-commands or in case you have a reference to a viewmodel you can just call methods directly... after all view models are java objects.
I am interested in knowing more about the scenarios you stated. i.e
having a navigation view model and separate view models dedicated to individual pages.
having a reference to a viewmodel you can just call methods directly.
can you share links to examples that illustrates this scenarios ?
mvvm navigation: http://books.zkoss.org/zkessentials-book/master/navigationandtemplate/ajaxbasednavigation-mvvm.html
call VM method directly: https://zkfiddle.org/sample/238847/1-update-other-viewmodel-via-java
a command handler in the outerVM calls the doSomething method on the innerVM
Asked: 2021-01-26 04:55:28 +0800
Seen: 24 times
Last updated: Feb 09 '21
bug with intboxes on mobile devices
zk keikai-how to add custom button/label to formulabar?
zk-keikai- update multiple cells parallel at same time asynchronously
zk-keikai-How to auto fit column width based on text
zk-keikai-ClipboardPateEvent-called twice
Reference a spring bean from VariableResolver