Friday, 27 April 2012

Dynamic Include Source

Dynamic Include Source

Let us see how we can dymanically set the source for the include Component

Our objective is if user clicks on male, then load another zul page. If user clicks on female
, then load another page.

Here is the Root Zul File

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<window title="Dynamic Include Example" id="rootWin"
<window id="innerWin">
<radiogroup id="radio">
<radio label="Male" />
<radio label="Female" />
<include id="innerIncld" />


Here is the female.zul

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<window title="Female" border="normal">Female zul File</window>

Here is the male.zul

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<window title="Male" border="normal">Male Zul file</window>

Here is the composer

package mypack;

import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Include;
import org.zkoss.zul.Radiogroup;

public class DynamicInclude extends GenericForwardComposer {

private static final long serialVersionUID = 1L;
Radiogroup innerWin$radio;
Include innerIncld;

public void onCheck$radio$innerWin() {
boolean tf = innerWin$radio.getSelectedItem().getLabel().equals("Male");
String s = tf ? "male.zul" : "female.zul";

No comments:

Post a Comment

Passing Parameter between two files using MVVM

This examples shows how to pass parameter between two zul screens. In this example, we are passing some parameters from the parent vm to...