Processing...
Description & Source Code

This sample demonstrates how border layout can be used to define complex layouts.

complex_border_layout.zul
<zk>
	<style>
		.breeze .complex-layout, .breeze .complex-layout .z-south, .breeze .complex-layout .z-west {
			background: #F7F7F7;
		}
		.z-borderlayout {  background: #FFFFFF }
		.complex-layout .z-north { background: #008BB6; }
		.complex-layout .z-north > div { padding: 5px; }
		img.complex-layout-header-img { padding: 0 10px; }
		.complex-layout-header-label {
			position: relative; top: -30px;
			padding-left: 40px; font-size: 24px;
			color: White; font-weight: bold;
		}
		.inner-border, .inner-border .z-north, .inner-border .z-west,
		.inner-border .z-south, .inner-border .z-east { background: #FFFFFF; }
		.dl-link { text-decoration: none; cursor: pointer; }
	</style>
	<div viewModel="@id('vm') @init('demo.layout.complex_border_layout.ComplexBorderlayoutViewModel')">
		<borderlayout sclass="complex-layout" height="810px">
			<north size="90px" border="0">
				<div>
					<div style="float:right">
						<textbox sclass="demo-search-inp" value="@bind(vm.search)" />
						<button label="Search ZK Resource"
							onClick="@command('search')" />
					</div>
					<image sclass="complex-layout-header-img"
						src="/images/ZK-Logo.gif" />
					<label sclass="complex-layout-header-label"
						value="ZK Project" />
				</div>
			</north>
			<!-- Sidebar -->
			<west width="200px" border="0" vflex="1" splittable="true"
				margins="0,5,0,0">
				<vlayout spacing="0">
					<panel width="100%" border="normal"
						title="Navigation">
						<panelchildren style="padding:5px;">
							<vlayout>
								<toolbarbutton label="Home" />
								<toolbarbutton label="Sitemap" />
								<toolbarbutton
									label="Statement of Direction" />
								<toolbarbutton label="ZK Team" />
								<toolbarbutton label="Releases" />
								<toolbarbutton label="Calender" />
							</vlayout>
						</panelchildren>
					</panel>
					<panel width="100%" border="normal"
						title="Why ZK ? ">
						<panelchildren>
							<html>
								<![CDATA[ <ul> <li>Productivity</li>
								<li>Security</li> <li>Performance</li>
								<li>Totally Control</li> <li>Auto
								Testing</li> <li>Scalability</li>
								<li>Flexibility</li> </ul> ]]>
							</html>
						</panelchildren>
					</panel>
					<panel width="100%" border="normal"
						title="Features">
						<panelchildren>
							<html>
								<![CDATA[ <ul> <li>Server+client
								Fusion</li> <li>Ajax-as-a-Service</li>
								<li>The Event Queue</li> <li>jQuery
								Based</li> <li>SEO Friendly</li>
								<li>Auto Testing</li> </ul> ]]>
							</html>
						</panelchildren>
					</panel>
				</vlayout>
			</west>
			<east width="130px" title="Quick Links" vflex="true">
				<vlayout>
					<html>
						<![CDATA[ <ul> <li>Tutorial</li> <li>Docs</li>
						<li>ZK vs GWT</li> <li>ZK vs Ajax JSF</li>
						<li>Forum</li> <li>FAQ</li> <li>Contact us</li>
						</ul> ]]>
					</html>
					<vlayout style="text-align:center;">
						<a href="http://www.zkoss.org/download/zk/ce"
							sclass="dl-link" target="_zkdemo">
							<image src="/images/DownloadNow.jpg" />
						</a>
						<toolbarbutton label="Download"
							href="http://www.zkoss.org/download/zk/ce" target="_zkdemo" />
					</vlayout>
				</vlayout>
			</east>
			<!-- Content -->
			<center>
				<borderlayout sclass="inner-border">
					<north border="0" height="4%" margins="2,3,0,0">
						<label value="HOME" style="font-size:20px;" />
					</north>
					<center border="0" margins="0,3,3,3">
						<panel title="Reference" border="normal"
							height="100%">
							<panelchildren>
								<grid style="border:0;">
									<rows>
										<row>
											<div>
												<image
													src="/images/Java_Logo.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="Java Doc" />
											</div>
										</row>
										<row>
											<div>
												<image
													src="/img/Centigrade-Widget-Icons/Calendar-16x16.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="Project Calendar" />
											</div>
										</row>
										<row>
											<div>
												<image
													src="/img/Centigrade-Widget-Icons/BookBlue-16x16.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="ZK Essentials" />
											</div>
										</row>
										<row>
											<div>
												<image
													src="/img/Centigrade-Widget-Icons/BookGreen-16x16.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="Developer's Reference" />
											</div>
										</row>
										<row>
											<div>
												<image
													src="/img/Centigrade-Widget-Icons/BookBrown-16x16.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="Component Essentials" />
											</div>
										</row>
										<row>
											<div>
												<image
													src="/img/Centigrade-Widget-Icons/Booklet-16x16.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="Style Guide" />
											</div>
										</row>
										<row>
											<div>
												<image
													src="/img/Centigrade-Widget-Icons/Envelope-16x16.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="Mailing Lists" />
											</div>
										</row>
										<row>
											<div>
												<image
													src="/images/twitter_16.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="Twitter" />
											</div>
										</row>
										<row>
											<div>
												<image
													src="/images/linkedin_16.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="LinkedIn" />
											</div>
										</row>
										<row>
											<div>
												<image
													src="/images/rss_16.png" />
												<separator
													orient="vertical" />
												<toolbarbutton
													label="RSS" />
											</div>
										</row>
									</rows>
								</grid>
							</panelchildren>
						</panel>
					</center>
					<east border="0" width="50%" margins="0,0,3,3">
						<panel title="Customer Overview" border="normal"
							height="100%" hflex="1">
							<panelchildren>
								Continent Contribution to Total Visitors
								<grid height="100%" model="@load(vm.contributions)">
									<columns>
										<column label="category"
											width="80px" />
										<column label="value" />
									</columns>
									<template name="model">
										<row>
											<label value="@load(each.area)" />
											<intbox value="@bind(each.value)" onChange="@command('updatePieModel')" />
										</row>
									</template>
								</grid>
							</panelchildren>
						</panel>
					</east>
					<south border="1" height="37%" margins="0,0,3,3">
						<panel border="normal">
							<panelchildren style="overflow:auto;">
								<chart id="mychart"
									title="User Location" type="pie" threeD="true" fgAlpha="128" model="@load(vm.pieModel)" onClick="@command('displayArea')" />
							</panelchildren>
						</panel>
					</south>
				</borderlayout>
			</center>
			<south size="40px" border="0"
				style="background: none repeat scroll 0 0 ;">
				<toolbar mold="panel" align="center">
					<toolbarbutton label="Sign in" />
					<toolbarbutton label="Home" />
					<toolbarbutton label="Sitemap" />
					<toolbarbutton label="Terms" />
					<toolbarbutton label="Report Abuse" />
					<toolbarbutton label="Print" />
					<separator orient="vertical" bar="true" />
					Powered by ZK ${desktop.webApp.version} ZK
					Borderlayout
				</toolbar>
			</south>
		</borderlayout>
	</div>
</zk>
ComplexBorderlayoutViewModel.java
package demo.layout.complex_border_layout;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Area;
import org.zkoss.zul.PieModel;
import org.zkoss.zul.SimplePieModel;

public class ComplexBorderlayoutViewModel {

	private static final String searchUrl = "http://www.zkoss.org/doc/searchresult.jsp?cx=008321236477929467003%3A63kdpeqkkvw&cof=FORID%3A11&q=";

	private String search;
	private List<Contribution> contributions = new ArrayList<Contribution>();
	private PieModel pieModel;

	@Init
	public void init() {
		contributions.add(new Contribution("Europe", 31));
		contributions.add(new Contribution("Africa", 4));
		contributions.add(new Contribution("Americas", 25));
		contributions.add(new Contribution("Oceania", 4));
		contributions.add(new Contribution("Asia", 29));
		contributions.add(new Contribution("Others", 4));

		createPieModel();
	}

	private void createPieModel() {
		pieModel = new SimplePieModel();

		for (Contribution contribution : contributions) {
			pieModel.setValue(contribution.getArea(), contribution.getValue());
		}
	}

	public String getSearch() {
		return search;
	}

	public void setSearch(String search) {
		this.search = search;
	}

	public PieModel getPieModel() {
		return pieModel;
	}

	public List<Contribution> getContributions() {
		return contributions;
	}

	@Command
	public void search() {
		if(StringUtils.isEmpty(search)) {
			Clients.showNotification("Search field must not be empty");
		} else {
			Executions.getCurrent().sendRedirect(searchUrl.concat(search), "_zk");
		}
	}

	@Command
	public void displayArea(@ContextParam(ContextType.TRIGGER_EVENT) MouseEvent event) {
		Component component = event.getAreaComponent();

		if (component instanceof Area) {
			Area area = (Area) component;
			Clients.alert(area.getAttribute("entity") + ":"
					+ area.getTooltiptext());
		}
	}

	@Command
	@NotifyChange("pieModel")
	public void updatePieModel() {
		createPieModel();
	}

	public static class Contribution {
		private String area;
		private int value;

		public Contribution(String country, int value) {
			super();
			this.area = country;
			this.value = value;
		}

		public String getArea() {
			return area;
		}

		public void setArea(String area) {
			this.area = area;
		}

		public int getValue() {
			return value;
		}

		public void setValue(int value) {
			this.value = value;
		}

	}
}