Using Panel to Lay out Your Website

Jumper Chen, Engineer, Potix Corporation
July 1, 2008

Introduction

In the past, we were used to using Window component as a container of UI manager to lay out the web page. However, the Window component, an independent ID space owner, separate each ID of its descendants from other Window component (a feature and also a limitation). In upcoming ZK 3.5.0, we make a Panel component, a non ID space owner, that has specific functionality and structural components that make it the perfect building block for application-oriented user interfaces. The Panel contains bottom, top, and foot toolbars, along with separate header, footer and body sections. It also provides built-in closable, collapsible, maximizable, and minimizable behavior, along with a variety of pre-built tool buttons that can be wired up to provide other customized behavior. Furthermore, Panel can be flexibly embedded into any kind of ZUL component that is allowed to have children or layout component. Panel also provides specific features like float and move. Unlike Window, Panel can only be floated and moved inside its parent node. In other words, the floated panel might not be floated in the whole page.

Live Demo

Let's have a look at a real case, a MSN-like application which layouts several ZK components into a Panel component.

The following fragment is the Panel example,

<panel id="panel" framable="true" width="500px" height="550px"
    title="Panel component" floatable="true" movable="true"
    maximizable="true" minimizable="true" border="normal"
    collapsible="true" closable="true">
        <toolbar>
          ... // Top Toolbar of the panel
        </toolbar>
        <panelchildren>
          ... // Each added child will show into the body content of the panel
        </panelchildren>
        <toolbar>
          ... // Bottom Toolbar of the panel
        </toolbar>
        <toolbar>
          ... // Foot Toolbar of the panel
        </toolbar>
</panel>

As you can see, the panel contains three Toolbar components and a Panelchildren component, which manages each child component, to construct the panel component that would produce on the web page. Let me explain each section as follows.

  • Title: You can use the setTitle() or the Caption component to show the title of the panel. Note that each built-in tool button, maximize, minimize, close, and collapse, is only applied when the title bar is shown.(It is an option)
  • Top Toolbar: It is used to show the top toolbar close to the body content of the panel.(It is an option)
  • Panelchildren: It is used to manage each child showing on the body content of the panel, and it supports any kind of ZUL component as its child.
  • Bottom Toolbar: It is used to show the bottom toolbar close to the body content of the panel. (It is an option)
  • Foot Toolbar: It is used to show the operating button under the body content with a few padding. (It is an option)

Combination

Here is a demo about combining Window with Panel.

As you can see, we use a Panel inside the Window to show the footer toolbar as a toolbar of the Window, and the Listbox inside the Panel can be scrolled as the content of the window.

Download

Download the panel-demo.war for the article here.

Version

Applicable to zk-3.5.0-FL-2008-07-01 and later.

Summary

Panel not only provides the fancy layout design, but also keeps the substance of ZK: Simple, Rich, and Flexible. If you come up with any problem, please feel free to ask us on ZK forum.

Comments
 
perell
2008-07-02

Very good!!!
when zk 3.5 will come?

jumperchen
2008-07-03

3.5 is the next major release targeting early September.

Cheers,
Jumper

Bernd
2008-07-04

Hi Jumper,

this is a superb tutorial showing the panel sections visually - very nice approach ( I would have wished that every component was introduced like that :-)

Greetings
Bernd

heanry
2008-07-05

不能下载啊,能不能发给我一份啊,谢谢。。

jumperchen
2008-07-07

Please take a look at the ZKDemowhich is upgrade to ZK 3.5.0 version.(including Panel and Columnlayout).

BTW, we'll provide a repository, which can be accessible from China area, about these recent files for China people.

Ivan
2008-07-09

Please download from this URL: http://twossf.zkoss.org/filedownload/

Ivan
2008-07-10

Sorry, This is correct URL: http://twossf.zkoss.org/filedownload/

hks
2008-07-13

your example does not work in zk 3.0.6 here is the error :
org.zkoss.zk.ui.metainfo.DefinitionNotFoundException: Component definition not found: panel in [LanguageDefinition: xul/html], [SYS file:C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/panel-demo/index.zul line 13 col 38]
org.zkoss.zk.ui.metainfo.Parser.parse(Parser.java:698)
org.zkoss.zk.ui.metainfo.Parser.parse(Parser.java:565)
org.zkoss.zk.ui.metainfo.Parser.parse(Parser.java:773)
org.zkoss.zk.ui.metainfo.Parser.parse(Parser.java:209)
org.zkoss.zk.ui.metainfo.Parser.parse(Parser.java:100)
org.zkoss.zk.ui.metainfo.PageDefinitions$MyLoader.parse(PageDefinitions.java:196)
org.zkoss.web.util.resource.ResourceLoader.load(ResourceLoader.java:94)
org.zkoss.util.resource.ResourceCache$Info.load(ResourceCache.java:228)
org.zkoss.util.resource.ResourceCache$Info.<init>(ResourceCache.java:202)
org.zkoss.util.resource.ResourceCache.get(ResourceCache.java:143)
org.zkoss.web.util.resource.ResourceCaches.get(ResourceCaches.java:131)
org.zkoss.zk.ui.metainfo.PageDefinitions.getPageDefinition(PageDefinitions.java:142)
org.zkoss.zk.ui.impl.AbstractUiFactory.getPageDefinition(AbstractUiFactory.java:115)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:219)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:167)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

hks
2008-07-13

ups sory... this is only work in 3.5.0

tAft
2008-07-23

Hello

In the easit demo, we could see Panel in action. Did they used the v3.5.0 or is it a simulation with components of the v3.0.6?

(sorry for my english)

xcbs
2008-07-25

By reading we enrich the mind; by conversation we polish it. http://www.laizjj.cn/

joe985
2008-07-25

Is there any way to use the Panel class from 3.0.5 release into a 3.0.6 ???

joe985
2008-07-25

Sorry my bad, I confuse 3.0.5 with 3.5.0.

paul
2008-08-29

your example and zkdemo does not work both in zk 3.0.6 and 3.0.5
(by eclipse 3.3.2 tomcat 5.5 and zk studio 0.8.1)
(I am very frustrated with the failure of running lots of zk demos except the helloworld example.
We like zk concepts and interested in zk product, but could you zk people kindly specify the exact running environment and related settings each time releasing a zk example?
That will save lots of time from the new comers.)

with the same error :
org.zkoss.zk.ui.metainfo.DefinitionNotFoundException: Component definition not found: panel in [LanguageDefinition: xul/html], [SYS file:C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/panel-demo/index.zul line 13 col 38]
org.zkoss.zk.ui.metainfo.Parser.parse(Parser.java:698)

 
 
Leave a Reply
 
Name (required)
Mail (will not be published) (required)
Website
(Case Insensitive)
Bold textItalic textUnderLine textSource CodeHorizontal rulerExternal Link
Post
Preview