answered
2018-06-19 20:26:47 +0800
cor3000 6280 ● 2 ● 7 the most basic way is to send a @global-command to the main viewmodel which then can update the url of the include:
in main.zul
<div viewModel="@id('vm') @init('my.org.MainViewModel')">
<include data="@load(vm.navigationData)" src="@load(vm.currentViewUrl)"/>
</div>
in main view model
public class MainViewModel {
...
@GlobalCommand
public void editPerson(@BindingParam("person") Person person) {
this.data = person;
this.currentViewUrl = "/person/edit.zul"
BindUtils.postNotifyChange(null, null, this, "data");
BindUtils.postNotifyChange(null, null, this, "currentViewUrl");
}
...
}
trigger the global command from anywhere else
e.g. from a zul file in a grid
<template name="model">
<row>
...
<cell>
<button label="edit" onClick="@global-command('editPerson', person=each)"
</cell>
</row>
</template>
or the same from java code
BindUtils.postGlobalCommand(null, null, "editPerson",
Collections.singletonMap("person", clickedPersonObject))
If this doesn't match your scenario please provide a runnable example on zkfiddle.org then I can add what's missing to help in your specific case.
Getting main page's <include> component in inner1.zul's ViewModel and reset its src value to inner2.zul
matthung ( 2018-06-13 09:34:18 +0800 )edit