Revision history [back]

click to hide/show revision 1
initial version

asked 2014-05-29 23:37:07 +0800

tomr gravatar image tomr

Page as ZUL component, multiple instances of the same MV on one page

I am investigating multi-tab solution for single-page application (something like zksample2). The requirements are that each new document (e.g. invoice) should be opened in new page. E.g. there can be "New invoice" command on the toolbar and when user clicks it two times, then 2 new tabs are opened and 2 new invoices are created (e.g. with Id 5 and 6).

The question is - how to implement such requirements.

My idea is to create new zul component that can be used for displaying invoice. That is clear. It is also clear how to create new instance of InvoiceZUL at runtime - the code can be similar to tab_plus demo code.

The problem is about reference to ModelView. My understanding is that 2 instances of ModelView should be created and assigned to some array of available ModelView's. The question is - how can I indicate that the instace 1 of InvoiceZUL should used instance 1 of InvoiceMV and instance 2 of InvoiceZUL should use instance 2 of InvoiceMV.

Static solution is to write code: viewModel="@id('vm') @init('org.zkoss.essentials.chapter6.mvvm.TodoListViewModel')"

Maybe such references can be created dynamically in the main ZUL file? E.g. maybe I can create dynamically reference vmi and indicate that invoiceZULi should used vm_i?

Does ZK supports such use cases?

Thanks for any suggestions in advance

Page as ZUL component, multiple instances of the same MV on one page

I am investigating multi-tab solution for single-page application (something like zksample2). The requirements are that each new document (e.g. invoice) should be opened in new page. E.g. there can be "New invoice" command on the toolbar and when user clicks it two times, then 2 new tabs are opened and 2 new invoices are created (e.g. with Id 5 and 6).

The question is - how to implement such requirements.

My idea is to create new zul component that can be used for displaying invoice. That is clear. It is also clear how to create new instance of InvoiceZUL at runtime - the code can be similar to tab_plus demo code.

The problem is about reference to ModelView. My understanding is that 2 instances of ModelView should be created and assigned to some array of available ModelView's. The question is - how can I indicate that the instace 1 of InvoiceZUL should used instance 1 of InvoiceMV and instance 2 of InvoiceZUL should use instance 2 of InvoiceMV.

Static solution is to write code: viewModel="@id('vm') @init('org.zkoss.essentials.chapter6.mvvm.TodoListViewModel')"

Maybe such references can be created dynamically in the main ZUL file? E.g. maybe I can create dynamically reference vmi and indicate that invoiceZULi should used vm_i?

Does ZK supports such use cases?

Thanks for any suggestions in advance

Page as ZUL component, multiple instances of the same MV VM on one page

I am investigating multi-tab solution for single-page application (something like zksample2). The requirements are that each new document (e.g. invoice) should be opened in new page. E.g. there can be "New invoice" command on the toolbar and when user clicks it two times, then 2 new tabs are opened and 2 new invoices are created (e.g. with Id 5 and 6).

The question is - how to implement such requirements.

My idea is to create new zul component that can be used for displaying invoice. That is clear. It is also clear how to create new instance of InvoiceZUL at runtime - the code can be similar to tab_plus demo code.

The problem is about reference to ModelView. My understanding is that 2 instances of ModelView should be created and assigned to some array of available ModelView's. The question is - how can I indicate that the instace 1 of InvoiceZUL should used instance 1 of InvoiceMV and instance 2 of InvoiceZUL should use instance 2 of InvoiceMV.

Static solution is to write code: viewModel="@id('vm') @init('org.zkoss.essentials.chapter6.mvvm.TodoListViewModel')"

Maybe such references can be created dynamically in the main ZUL file? E.g. maybe I can create dynamically reference vmi and indicate that invoiceZULi should used vm_i?

Does ZK supports such use cases?

And one more question. Event names are usually hard-coded in the class of ViewModel. All is clear if only one ViewModel exists. But what happens if one ZUL pages uses multiple instances of the same ViewModel class. E.g. to distinct Invoices are being edited and use clicks on Invoice Id 5 to save data. SaveInvoice event is raised and how can ZK binder determine that instance InvoiceVM[5] should handle this event and not other instances?

Thanks for any suggestions in advance

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