Revision history [back]

click to hide/show revision 1
initial version

asked 2021-01-26 04:55:28 +0800

RomanZK gravatar image RomanZK

Multiple ViewModels in a zul

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

  1. what are the usage scenarios for using more than one view model in a zul page ?

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

Multiple ViewModels in a zul

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') border="normal"
         apply="org.zkoss.bind.BindComposer"
         viewModel="@id('vm') @init('com.MyVM')" hflex="1" vflex="1" contentstyle="overflow:auto">

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

  1. what are the usage scenarios for using more than one view model in a zul page ?

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

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More