ITeye博客

ZK 控件

编程足球 · 2012-05-10 15:35 · ZK · Web前端 · Markdown

1.ZK 客户端和服务端之间的交互

官网对上图的解释如下:

When a ZK application runs on the server, it can have access to the backend resources, assemble UI with components, listen to user's activity, and then manipulate components to update UI. All are done at the server. The synchronization of the states of the components between the browser and the server is done automatically by ZK and transparently to the application. When running at the server, the application can access full Java technology stack. User activities, including Ajax and Server Push, are abstracted to event objects. UI are composed of POJO-like components. ZK is the most productive approach to develop a modern Web application.

2. ZK UI开发可以用zul或纯java代码来实现


<window title="ZK Essentials" border="normal" width="250px">
      <button label="Hello"/>
      <button label="Good-bye "/>
</window>

等同于下面的


Window win = new Window();
      win.setTitle("ZK Essentials");
      win.setBorder("normal");
      win.setWidth("250px");
Button helloBtn = new Button();
      helloBtn.setLabel("Hello");
      helloBtn.setParent(win);
Button byeBtn = new Button();
      byeBtn.setLabel("Good-bye");
      byeBtn.setParent(win);

3. ZK UI的创建

Components declared using ZUML in a ZUL file are parsed by a ZK enhanced XML parser. The components declared are created as Plain Old Java Objects (POJO) in the JVM on the server. Suppose we have a ZUL page that outlines the tree of components. Please see the following:

4. 在java中查找控件 Finding a Component Programmatically in Java 例子如下:

  1. java 代码生成的UI

Window outerWin = new Window();
Button outerBtn = new Button();
btn.setParent(outerWin);
Window innerWin = new Window();
innerWin.setParent(outerWin);
Button innerBtn = new Button();
innerBtn.setParent(innerWin);

  1. zul代码生成的UI

<window id="outerWin">
       <button id="outerBtn">
        <window id="innerWin">
             <button id="innerBtn"/>
        </window>
</window>

结构图如下:

在相同的ID空间中可以使用 getFellow 方法来获得控件 We can call the getFellow method on any component to access another component in the same ID Space.


Window innerWin = (Window)outerWin.getFellow("innerWin");

可以使用的方法如下:

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。