-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have defined a composite component that uses the following zul:
<div id="backpackWrap" apply="org.zkoss.bind.BindComposer" viewModel="@id('bvm') @init('foo.bar.CompView')">
<Component/>
<Component/>
</div>
When I use the composite component on the page, I get the following error:
org.zkoss.zk.ui.UiException: can't find Page to resolve a view model class :'foo.bar.CompView'
Is it possible to use a ViewModel inside the zul of a composite component ? If so how do I get this to work ?
Thanks,
Hi All,
I found a workaround for this, the composite component requires two zul files... Create an additional zull file for the composite component that is an include component with no src:
<include id="contentInclude"/>
In the composite component Java afterCompose method set the src of the include the the url of the zul that contains the view model and wire components again. Since the component is attached to a page before the include src is set everything works fine.
afterCompose(){
contentInclude.setSrc("path/to/zul/with/viewmodel.zul");
Selectors.wireVariables(this, this, null);
Selectors.wireComponents(this, this, false);
Selectors.wireEventListeners(this, this);
}
Asked: 2015-05-22 05:10:07 +0800
Seen: 33 times
Last updated: May 27 '15