Suggested case list:
Using timer to refresh a grid
383guest172.69.33.12125nk0uiMay 7, 2020 7:23:47 AMlinkuser model to move item to another listbox
120guest162.158.193.148d0n3krApr 2, 2020 5:28:28 AMlinkDisabled list item row passed to VM-1981
296fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:44 PMlinkDisabled list item row passed to VM-1981
295fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:16 PMlinkDisabled list item row passed to VM-1981
294fatih123160.83.36.13225nk0uiFeb 13, 2018 3:30:44 PMlinkgrid sample with ListModel/RowRenderer
816guest80.82.2.1312vah9ajFeb 21, 2017 11:42:21 AMlinkgrid sample with ListModel/RowRenderer
809guest175.98.113.1622vah9ajJan 26, 2017 9:19:33 AMlinkgrid sample with ListModel/RowRenderer
196guest79.185.142.402vah9ajApr 26, 2014 10:53:57 PMlinkgrid sample with ListModel/RowRenderer
195guest79.185.142.402vah9ajApr 26, 2014 10:53:54 PMlinkgrid sample with ListModel/RowRenderer
194guest79.185.142.402vah9ajApr 26, 2014 10:53:51 PMlinkgrid sample with ListModel/RowRenderer
193guest79.185.142.402vah9ajApr 26, 2014 10:53:48 PMlinkgrid sample with ListModel/RowRenderer
192guest79.185.142.402vah9ajApr 26, 2014 10:53:44 PMlinkgrid sample with ListModel/RowRenderer
191guest79.185.142.402vah9ajApr 26, 2014 10:53:40 PMlinkHierarchy table without using ZK PE/EE
1aaknai151.28.135.2131s871daJul 29, 2013 11:02:46 PMlinkgrid sample with ListModel/RowRenderer
128aaknai151.28.135.2132vah9ajJul 29, 2013 7:20:00 PMlinkuser model to move item to another listbox
1TonyQ114.25.109.94d0n3krApr 21, 2012 10:43:27 AMlinkUsing timer to refresh a grid
1TonyQ220.133.44.3725nk0uiFeb 17, 2012 3:17:34 AMlinkFire a event from child iframe
1TonyQ220.133.44.372eupjotFeb 3, 2012 5:04:52 AMlinkTextbox input restriction sample
1TonyQ72.21.245.2431b3nlr0Dec 20, 2011 10:09:10 AMlinkTest web core taglib in ZUL
1TonyQ198.203.175.175ofqkemDec 17, 2011 3:36:08 AMlinkLatest 10 Fiddles :
constraint binding textbox
3guest172.68.151.16220peldaDec 5, 2025 5:08:19 PMlinkAnother new ZK fiddle
2guest172.68.151.16320peldaDec 5, 2025 5:07:51 PMlinkAnother new ZK fiddle
1guest172.68.151.16220peldaDec 5, 2025 5:07:32 PMlinkAnother new ZK fiddle
1peggypeng172.71.154.99364f4neDec 5, 2025 9:24:31 AMlinktooltip example
2guest104.22.23.13rc1ntoDec 4, 2025 2:23:45 PMlinkAnother new ZK fiddle
1guest172.69.134.2277t7602Dec 4, 2025 1:40:46 PMlinkAnother new ZK fiddle
1peggypeng104.22.17.1802df6e3oDec 4, 2025 8:41:29 AMlinkonClose
1peggypeng172.68.87.248j8kd8aDec 3, 2025 4:10:26 AMlinkAnother new ZK fiddle
1peggypeng172.69.134.2271rm7f4eNov 26, 2025 3:31:24 AMlinkZK-5912-Suggestion
2rebeccalai104.22.20.1442qrmiiuNov 26, 2025 2:07:15 AMlinkAnother new ZK fiddle
8guest181.24.35.21919mrukmFeb 29, 2016 11:21:19 PMlinkresources
index.zulzul<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<zk>
<window id="win" apply="org.zkoss.zkfusionchartdemo.FusionchartDemoComposer" height="100%">
<borderlayout height="100%">
<north vflex="min">
<panel border="normal" framable="true" height="100%">
<panelchildren>
<checkbox label="threeD"
checked="@{attr.threeD}" />
<checkbox label="use ChartConfig"
checked="@{attr.useChartConfig}" />
<radiogroup
selectedIndex="@{attr.orient, converter='org.zkoss.zkfusionchartdemo.OrientConverter'}">
<radio label="vertical"/>
<radio label="horizontal"/>
</radiogroup>
<checkbox label="Show Gantt Chart Table" forward="onCheck=onShowTable"/>
</panelchildren>
</panel>
</north>
<west size="150px">
<listbox id="typeList" selectedIndex="@{attr.type, converter='org.zkoss.zkfusionchartdemo.ChartTypeConverter'}">
<listitem label="Pie Chart" value="pie"/>
<listitem label="Bar Chart" value="bar"/>
<listitem label="Stacked Bar Chart" value="stacked_bar"/>
<listitem label="Line Chart" value="line"/>
<listitem label="Area Chart" value="area"/>
<listitem label="Stacked Area Chart" value="stacked_area"/>
<listitem label="Gantt Chart" value="gantt"/>
<listitem label="Combination Chart" value="combination"/>
</listbox>
</west>
<center autoscroll="true">
<vlayout>
<chart id="chart" title="@{attr.type}" width="500" height="250" type="@{attr.type}"
model="@{attr.model}" orient="@{attr.orient}" threeD="@{attr.threeD}"
forward="onChartClick" />
<fusionchart id="fchart" title="@{attr.type}" width="500" height="250" type="@{attr.type}"
model="@{attr.model}" orient="@{attr.orient}" threeD="@{attr.threeD}"
chartConfig="@{attr.chartConfig}"
forward="onChartClick" />
</vlayout>
</center>
</borderlayout>
</window>
</zk> ChartTypeConverter.javajava/* ChartTypeConverter.java
Purpose:
Description:
History:
Jul 17, 2011 4:35:10 PM, Created by jimmyshiau
Copyright (C) 2011 Potix Corporation. All Rights Reserved.
{{IS_RIGHT
This program is distributed under LGPL Version 3.0 in the hope that
it will be useful, but WITHOUT ANY WARRANTY.
}}IS_RIGHT
*/
import java.util.Iterator;
import org.zkoss.zkplus.databind.TypeConverter;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
/**
* @author jimmy
*
*/
public class ChartTypeConverter implements TypeConverter {
public Object coerceToBean(java.lang.Object val,
org.zkoss.zk.ui.Component comp) {
return ((Listbox) comp).getSelectedItem().getValue();
}
public Object coerceToUi(java.lang.Object val,
org.zkoss.zk.ui.Component comp) {
Listbox lb = (Listbox) comp;
int index = 0;
for (Iterator it = lb.getItems().iterator(); it.hasNext(); index++) {
Listitem item = (Listitem) it.next();
if (val.equals(item.getValue())) {
item.setSelected(true);
break;
}
}
return "";
}
}timeout.zulzul<window width="80%" title="Session Timeout" border="normal">
<vbox>
The page or component you request is no longer available.
This is normally caused by timeout, opening too many Web pages, or rebooting
the server.
</vbox>
</window>FusionchartDemoComposer.javajava
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.zkoss.fusionchart.Fusionchart;
import org.zkoss.fusionchart.api.GanttTableRenderer;
import org.zkoss.fusionchart.config.CategoriesConfig;
import org.zkoss.fusionchart.config.CategoryChartConfig;
import org.zkoss.fusionchart.config.ChartConfig;
import org.zkoss.fusionchart.config.GanttChartCategoriesConfig.GanttChartCategoriesProperties;
import org.zkoss.fusionchart.config.GanttChartConfig;
import org.zkoss.fusionchart.config.GanttChartSeriesConfig;
import org.zkoss.fusionchart.config.GanttTableConfig;
import org.zkoss.fusionchart.config.GanttTableConfig.GanttRow;
import org.zkoss.fusionchart.config.GanttTableConfig.GanttTableColumnConfig;
import org.zkoss.fusionchart.config.PieChartConfig;
import org.zkoss.fusionchart.config.SeriesConfig;
import org.zkoss.fusionchart.config.XYChartConfig;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.CheckEvent;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.ForwardEvent;
import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Area;
import org.zkoss.zul.CategoryModel;
import org.zkoss.zul.Chart;
import org.zkoss.zul.ChartModel;
import org.zkoss.zul.GanttModel;
import org.zkoss.zul.GanttModel.GanttTask;
import org.zkoss.zul.ListModel;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.PieModel;
import org.zkoss.zul.SimpleCategoryModel;
import org.zkoss.zul.SimplePieModel;
import org.zkoss.zul.SimpleXYModel;
import org.zkoss.zul.XYModel;
public class FusionchartDemoComposer extends GenericForwardComposer {
private static final Map DEFAULT_MODEL = new HashMap();
private static final Map DEFAULT_CONF = new HashMap();
private static final ChartModel CATE_MODEL = createCategoryModel();
private static final ChartModel XY_MODEL = createXYModel();
private static final CategoryChartConfig CATE_CONF = createCategoryChartConfig();
private static final XYChartConfig XY_CONF = createXYChartConfig();
static {
DEFAULT_MODEL.put(Chart.PIE, createPieModel());
DEFAULT_MODEL.put(Chart.BAR, CATE_MODEL);
DEFAULT_MODEL.put(Chart.STACKED_BAR, CATE_MODEL);
DEFAULT_MODEL.put(Chart.LINE, XY_MODEL);
DEFAULT_MODEL.put(Chart.AREA, XY_MODEL);
DEFAULT_MODEL.put(Chart.STACKED_AREA, XY_MODEL);
DEFAULT_MODEL.put(Chart.GANTT, createGanttModel());
DEFAULT_MODEL.put(Fusionchart.COMBINATION, CATE_MODEL);
DEFAULT_CONF.put(Chart.PIE, createPieChartConfig());
DEFAULT_CONF.put(Chart.BAR, CATE_CONF);
DEFAULT_CONF.put(Chart.STACKED_BAR, CATE_CONF);
DEFAULT_CONF.put(Chart.LINE, XY_CONF);
DEFAULT_CONF.put(Chart.AREA, XY_CONF);
DEFAULT_CONF.put(Chart.STACKED_AREA, XY_CONF);
DEFAULT_CONF.put(Chart.GANTT, createGanttChartConfig());
DEFAULT_CONF.put(Fusionchart.COMBINATION, createCombiCategoryChartConfig());
}
private Listbox typeList;
private Chart chart;
private Fusionchart fchart;
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
if (!session.hasAttribute("attr")) {
session.setAttribute("attr", new AttrController());
}
comp.setAttribute("attr", session.getAttribute("attr"));
}
private static PieModel createPieModel() {
PieModel piemodel = new SimplePieModel();
piemodel.setValue("C/C++", new Double(12.5));
piemodel.setValue("Java", new Double(50.2));
piemodel.setValue("VB", new Double(20.5));
piemodel.setValue("PHP", new Double(15.5));
return piemodel;
}
private static CategoryModel createCategoryModel() {
CategoryModel catmodel = new SimpleCategoryModel();
catmodel.setValue("2001", "Q1", new Integer(20));
catmodel.setValue("2001", "Q2", new Integer(35));
catmodel.setValue("2001", "Q3", new Integer(40));
catmodel.setValue("2001", "Q4", new Integer(55));
catmodel.setValue("2002", "Q1", new Integer(40));
catmodel.setValue("2002", "Q2", new Integer(60));
catmodel.setValue("2002", "Q3", new Integer(70));
catmodel.setValue("2002", "Q4", new Integer(90));
return catmodel;
}
private static XYModel createXYModel() {
XYModel xymodel = new SimpleXYModel();
xymodel.addValue("2001", new Integer(10), new Integer(1459));
xymodel.addValue("2001", new Integer(20), new Integer(1423));
xymodel.addValue("2001", new Integer(30), new Integer(1382));
xymodel.addValue("2001", new Integer(40), new Integer(1356));
xymodel.addValue("2001", new Integer(50), new Integer(1310));
xymodel.addValue("2001", new Integer(60), new Integer(1282));
xymodel.addValue("2001", new Integer(70), new Integer(1247));
xymodel.addValue("2001", new Integer(80), new Integer(1182));
xymodel.addValue("2002", new Integer(10), new Integer(1188));
xymodel.addValue("2002", new Integer(20), new Integer(1189));
xymodel.addValue("2002", new Integer(30), new Integer(1177));
xymodel.addValue("2002", new Integer(40), new Integer(1175));
xymodel.addValue("2002", new Integer(50), new Integer(1210));
xymodel.addValue("2002", new Integer(60), new Integer(1280));
xymodel.addValue("2002", new Integer(70), new Integer(1390));
xymodel.addValue("2002", new Integer(80), new Integer(1524));
return xymodel;
}
private static GanttModel createGanttModel() {
GanttModel ganttmodel = new GanttModel();
ganttmodel.addValue("Scheduled", new GanttTask("Write Proposal",
date(2008, 4, 1), date(2008, 4, 5), 0.0));
ganttmodel.addValue("Scheduled", new GanttTask("Requirements Analysis",
date(2008, 4, 10), date(2008, 5, 5), 0.0));
ganttmodel.addValue("Scheduled", new GanttTask("Design Phase",
date(2008, 5, 6), date(2008, 5, 30), 0.0));
ganttmodel.addValue("Scheduled", new GanttTask("Alpha Implementation",
date(2008, 6, 3), date(2008, 7, 31), 0.0));
ganttmodel.addValue("Actual", new GanttTask("Write Proposal",
date(2008, 4, 1), date(2008, 4, 3), 0.0));
ganttmodel.addValue("Actual", new GanttTask("Requirements Analysis",
date(2008, 4, 10), date(2008, 5, 15), 0.0));
ganttmodel.addValue("Actual", new GanttTask("Design Phase",
date(2008, 5, 15), date(2008, 6, 17), 0.0));
ganttmodel.addValue("Actual", new GanttTask("Alpha Implementation",
date(2008, 7, 1), date(2008, 9, 12), 0.0));
return ganttmodel;
}
private static Date date(int year, int month, int day) {
final java.util.Calendar calendar = java.util.Calendar.getInstance();
calendar.set(year, month - 1, day);
return calendar.getTime();
}
private static PieChartConfig createPieChartConfig() {
PieChartConfig config = new PieChartConfig();
config.setPieFillAlpha(95);
config.setAnimation(false);
config.addProperty("pieBorderColor", "FFFFFF");
CategoriesConfig cConfig = config.getCategoryConfig();
cConfig.createCategoryProperties("C/C++").addProperty("color", "AFD8F8");
cConfig.createCategoryProperties("Java")
.addProperty("color", "8BBA00").addProperty("isSliced", "1");
cConfig.createCategoryProperties(2).addProperty("color", "F6BD0F");
cConfig.createCategoryProperties(3).addProperty("color", "A66EDD");
return config;
}
private static CategoryChartConfig createCategoryChartConfig() {
CategoryChartConfig config = new CategoryChartConfig();
config.setAnimation(false);
config.addProperty("rotateNames", "1");
SeriesConfig sConfig = config.getSeriesConfig();
sConfig.createSeriesProperties(0)
.addProperty("color", "AFD8F8").addProperty("parentYAxis", "P");
sConfig.createSeriesProperties(1)
.addProperty("color", "FF8000").addProperty("parentYAxis", "S")
.addProperty("anchorBorderColor", "FF8000")
.addProperty("lineThickness", "4");
return config;
}
private static XYChartConfig createXYChartConfig() {
XYChartConfig config = new XYChartConfig();
SeriesConfig sConfig = config.getSeriesConfig();
sConfig.createSeriesProperties(0)
.addProperty("color", "0099FF")
.addProperty("alpha", "100")
.addProperty("anchorAlpha", "0")
.addProperty("lineThickness", "2");
sConfig.createSeriesProperties(1)
.addProperty("color", "FF8000")
.addProperty("alpha", "80")
.addProperty("showAnchors", "0");
return config;
}
private static CategoryChartConfig createCombiCategoryChartConfig() {
CategoryChartConfig config = new CategoryChartConfig();
config.setAnimation(false);
config.setCanvasBgColor("F6DFD9");
config.addProperty("canvasBaseColor", "FE6E54");
config.addProperty("numberPrefix", "$");
SeriesConfig sConfig = config.getSeriesConfig();
sConfig.createSeriesProperties(0)
.addProperty("color", "9ACCF6").addProperty("alpha", "90");
sConfig.createSeriesProperties(1)
.addProperty("color", "82CF27").addProperty("alpha", "90")
.addProperty("parentYAxis", "S");
return config;
}
private static GanttChartConfig createGanttChartConfig() {
GanttChartConfig config = new GanttChartConfig();
config.addProperty("canvasBorderColor", "024455")
.addProperty("canvasBorderThickness", "0");
GanttChartCategoriesProperties cProps =
config.getCategoriesConfig().createCategoriesProperties();
cProps.addProperty("bgColor", "4567aa");
cProps.createCategoryProperties("Months",
date(2008, 4, 1), date(2008, 9, 30))
.addProperty("align", "center")
.addProperty("font", "Verdana")
.addProperty("fontColor", "ffffff")
.addProperty("isBold", "1")
.addProperty("fontSize", "16");
config.getHeaderConfig()
.addProperty("bgColor", "ffffff")
.addProperty("fontColor", "1288dd")
.addProperty("fontSize", "10");
config.getProcessConfig()
.addProperty("bgColor", "4567aa")
.addProperty("fontColor", "ffffff")
.addProperty("fontSize", "10")
.addProperty("headerVAlign", "right")
.addProperty("headerbgColor", "4567aa")
.addProperty("headerFontColor", "ffffff")
.addProperty("headerFontSize", "16")
.addProperty("width", "80")
.addProperty("align", "left");
config.getTasksProperties().addProperty("width", "10");
GanttChartSeriesConfig sConfig = config.getSeriesConfig();
sConfig.createSeriesProperties("Scheduled")
.addProperty("color", "4567aa");
sConfig.createSeriesProperties("Actual")
.addProperty("color", "cccccc");
defineGanttTable(config.getTableConfig());
return config;
}
private static void defineGanttTable(GanttTableConfig config) {
config.addProperty("nameAlign", "left")
.addProperty("fontColor", "000000")
.addProperty("fontSize", "10")
.addProperty("headerBgColor", "00ffff")
.addProperty("headerFontColor", "4567aa")
.addProperty("headerFontSize", "11")
.addProperty("vAlign", "right")
.addProperty("align", "left");
GanttTableColumnConfig cConfig = config.getColumnConfig();
cConfig.createColumnProperties(0)
.addProperty("headerText", "Dur")
.addProperty("align", "center")
.addProperty("headerfontcolor", "ffffff")
.addProperty("headerbgColor", "4567aa")
.addProperty("bgColor", "eeeeee");
cConfig.createColumnProperties(1)
.addProperty("headerText", "Cost")
.addProperty("align", "right")
.addProperty("headerfontcolor", "ffffff")
.addProperty("headerbgColor", "4567aa")
.addProperty("bgColor", "4567aa")
.addProperty("bgAlpha", "25");
}
private static ListModel createGanttTableModel() {
ListModelList model = new ListModelList();
model.add(new String[]{"150","$400"});
model.add(new String[]{"340","$890"});
model.add(new String[]{"60","$1234"});
model.add(new String[]{"20","$230"});
return model;
}
private static GanttTableRenderer createGanttTableRenderer() {
return new GanttTableRenderer() {
public void render(GanttRow row, Object data) throws Exception {
String[] s = (String[])data;
row.createLabel(s[0]);
row.createLabel(s[1]);
}
};
}
public void onSelect$typeList() {
if (Chart.GANTT.equals(typeList.getSelectedItem().getValue())) {
chart.setWidth("750");
chart.setHeight("450");
fchart.setWidth("750");
fchart.setHeight("450");
} else {
chart.setWidth("500");
chart.setHeight("250");
fchart.setWidth("500");
fchart.setHeight("250");
}
}
public void onShowTable(ForwardEvent evt) {
CheckEvent event = (CheckEvent) evt.getOrigin();
if (event.isChecked()) {
fchart.setTableModel(createGanttTableModel());
fchart.setTableRenderer(createGanttTableRenderer());
} else {
fchart.setTableModel(null);
fchart.setTableRenderer(null);
}
}
public void onChartClick(ForwardEvent evt) {
doCategoryChartClick(evt);
}
private void doCategoryChartClick(ForwardEvent evt) {
Event event = (Event) evt.getOrigin();
if (event instanceof MouseEvent) {
Component obj = ((MouseEvent) event).getAreaComponent();
if (obj != null) {
Area area = (Area) obj;
System.out.print(area.getAttribute("series") + " = "
+ area.getTooltiptext());
}
} else {
Map data = (Map) event.getData();
ChartModel model = ((Fusionchart) event.getTarget()).getModel();
if (model instanceof CategoryModel) {
System.out.print(data.get("series") + ", "
+ data.get("category") + " = " + data.get("value"));
} else if (model instanceof PieModel) {
System.out.print(data.get("category") + " = "
+ data.get("value"));
} else if (model instanceof XYModel) {
System.out.print(data.get("series") + " = " + data.get("x")
+ ", " + data.get("y"));
} else if (model instanceof GanttModel) {
GanttModel.GanttTask task = (GanttTask) data.get("task");
System.out.print(data.get("series") + ", "
+ task.getDescription() + " = " + task.getStart()
+ " ~ " + task.getEnd());
}
}
System.out.println();
}
public class AttrController {
private boolean threeD = false;
private String orient = "vertical";
private String type = "pie";
private boolean stacked = false;
private ChartModel model;
private boolean useChartConfig = false;
private ChartConfig chartConfig;
public AttrController() {
super();
this.model = (ChartModel) DEFAULT_MODEL.get(type);
}
public boolean isThreeD() {
return threeD;
}
public void setThreeD(boolean threeD) {
this.threeD = threeD;
}
public void setOrient(String orient) {
//"vertical" : "horizontal"
this.orient = orient;
}
public String getOrient() {
return orient;
}
public boolean isStacked() {
return stacked;
}
public void setStacked(boolean stacked) {
this.stacked = stacked;
}
public void setType(String type) {
this.type = type;
setModel((ChartModel) DEFAULT_MODEL.get(type));
if (useChartConfig)
setChartConfig((ChartConfig) DEFAULT_CONF.get(type));
}
public String getType() {
return type;
}
public void setModel(ChartModel model) {
this.model = model;
}
public ChartModel getModel() {
return model;
}
public boolean isUseChartConfig() {
return useChartConfig;
}
public void setUseChartConfig(boolean useChartConfig) {
this.useChartConfig = useChartConfig;
setChartConfig(useChartConfig ?
(ChartConfig) DEFAULT_CONF.get(type): null);
}
public ChartConfig getChartConfig() {
return chartConfig;
}
public void setChartConfig(ChartConfig chartConfig) {
this.chartConfig = chartConfig;
}
}
}