Revision history [back]

click to hide/show revision 1
initial version

answered 2015-08-24 08:22:03 +0800

cyiannoulis gravatar image cyiannoulis

Actually you can and quite easily i believe. Check the following snippets:

A main page:

<window border="none" height="100%" width="100%"
        xmlns:w="client"
        apply="org.zkoss.bind.BindComposer" 
        viewModel="@id('vm') @init('test.IndexVM')">

<button label="Include A" w:onClick="include('A.zul')" />
<button label="Include B" w:onClick="include('B.zul')" />

<include id="container" src="@load(vm.includePagePath)" 
    onInclude="@command('set-include-src', path=event.getData())" />

<script type="text/javascript">
<![CDATA[

    function include(path) {
        zAu.send(new zk.Event(zk.Widget.$('$container'), 'onInclude', path));
    }

]]></script>

</window>

And a simple view model command which changes the 'src' attribute of the include page:

@Command("set-include-src")
@NotifyChange("includePagePath")
public void onSetIncludeSrc(@BindingParam("path") String path) {
    includePagePath = path;
}

This is a very simple and readable way to listen for native js events and then posting custom events to any of your zul widgets.

hope that helps

Costas

Actually you can and do it quite easily i believe. easily. Of course zk is server-based so the client request must be forwarded in some way to the server but this can be done transparently using a simple custom event. Check the following snippets:

A main page:

<window border="none" height="100%" width="100%"
        xmlns:w="client"
        apply="org.zkoss.bind.BindComposer" 
        viewModel="@id('vm') @init('test.IndexVM')">

<button label="Include A" w:onClick="include('A.zul')" />
<button label="Include B" w:onClick="include('B.zul')" />

<include id="container" src="@load(vm.includePagePath)" 
    onInclude="@command('set-include-src', path=event.getData())" />

<script type="text/javascript">
<![CDATA[

    function include(path) {
        zAu.send(new zk.Event(zk.Widget.$('$container'), 'onInclude', path));
    }

]]></script>

</window>

And a simple view model command which changes the 'src' attribute of the include page:

@Command("set-include-src")
@NotifyChange("includePagePath")
public void onSetIncludeSrc(@BindingParam("path") String path) {
    includePagePath = path;
}

This is a very simple and readable way to listen for native js events and then posting custom events to any of your zul widgets.

hope that helps

Costas

Actually you can do it quite easily. Of course zk is server-based so the client request must be forwarded in some way to the server but this can be done transparently using a simple custom user event. Check the following snippets:

A main page:

<window border="none" height="100%" width="100%"
        xmlns:w="client"
        apply="org.zkoss.bind.BindComposer" 
        viewModel="@id('vm') @init('test.IndexVM')">

<button label="Include A" w:onClick="include('A.zul')" />
<button label="Include B" w:onClick="include('B.zul')" />

<include id="container" src="@load(vm.includePagePath)" 
    onInclude="@command('set-include-src', path=event.getData())" />

<script type="text/javascript">
<![CDATA[

    function include(path) {
        zAu.send(new zk.Event(zk.Widget.$('$container'), 'onInclude', path));
    }

]]></script>

</window>

And a simple view model command which changes the 'src' attribute of the include page:

@Command("set-include-src")
@NotifyChange("includePagePath")
public void onSetIncludeSrc(@BindingParam("path") String path) {
    includePagePath = path;
}

This is a very simple and readable way to listen for native js events and then posting post custom events to any of your zul widgets.widgets all of this running on the client side. The server-side part is just the @command that will be executed when the 'onInclude' event is received by the div.

hope that helps

Costas

Actually you can do it quite easily. Of course zk is server-based so the client request must be forwarded in some way to the server but this can be done transparently using a simple user event. Check the following snippets:

A main page:

<window border="none" height="100%" width="100%"
        xmlns:w="client"
        apply="org.zkoss.bind.BindComposer" 
        viewModel="@id('vm') @init('test.IndexVM')">

<button label="Include A" w:onClick="include('A.zul')" />
<button label="Include B" w:onClick="include('B.zul')" />

<include id="container" src="@load(vm.includePagePath)" 
    onInclude="@command('set-include-src', path=event.getData())" />

<script type="text/javascript">
<![CDATA[

    function include(path) {
        zAu.send(new zk.Event(zk.Widget.$('$container'), 'onInclude', path));
    }

]]></script>

</window>

And a simple view model command which changes the 'src' attribute of the include page:

@Command("set-include-src")
@NotifyChange("includePagePath")
public void onSetIncludeSrc(@BindingParam("path") String path) {
    includePagePath = path;
}

This is a very simple to listen for native js events and then post custom events to any of your zul widgets all of this running on the client side. The server-side part is just the @command that will be executed when the 'onInclude' event is received by the div.widgets.

hope that helps

Costas

Actually you can do it quite easily. Of course zk is server-based so the client request must be forwarded in some way to the server but this can be done transparently using a simple user event. Check the following snippets:

A main page:

<window border="none" height="100%" width="100%"
        xmlns:w="client"
        apply="org.zkoss.bind.BindComposer" 
        viewModel="@id('vm') @init('test.IndexVM')">

<button label="Include A" w:onClick="include('A.zul')" />
<button label="Include B" w:onClick="include('B.zul')" />

<include id="container" src="@load(vm.includePagePath)" 
    onInclude="@command('set-include-src', path=event.getData())" />

<script type="text/javascript">
<![CDATA[

    function include(path) {
        zAu.send(new zk.Event(zk.Widget.$('$container'), 'onInclude', path));
    }

]]></script>

</window>

And a simple view model command which changes the 'src' attribute of the include page:

@Command("set-include-src")
@NotifyChange("includePagePath")
public void onSetIncludeSrc(@BindingParam("path") String path) {
    includePagePath = path;
}

This is a very simple example how to listen for native js events and then post custom events to any of your zul widgets.

hope that helps

Costas

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