Status

Blog::Calendar

« September 2010
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  
       
Today
XML

Blog::Navigation

Blog::Editing

Bookmarks::Blogroll

Blog::Referers

Today''s Page Hits: 383

Other sites

Google Analytics

Powered by Roller Weblogger.
All | JBoss&Seam | JSF | ZK | Music | General | Java
« How to Integrate... | Main | How to write ZK... »
20070426 Thursday April 26, 2007
How to write ZK Forge Component

How to write ZK Forge Component

There are three simple ZK Forge Components in this document.

1.       HelloWorld

A Simple Hello World Example which tutor how to write a ZK Forge Component

2.       MyButton

A Simple Button Example which tutor how to send simple event to Server

3.       MyPanel

This Panel have 2 built-in buttons, ok&cancel button, In this sample,

l           I show 3 different mold in panel, default(bottom), right and left to place these 2 buttons.

l           I also show how to send 2 private event(onPanelOK & onPanelCancel) to server.

onPaneOk is always asap event and onPanelCancel can be defined asap or not by user's Listener

Project structure

 

/archive/ : This Folder store files that will be copied into atticZKForge.jar file.

/metainfo/zk/lang-addon.xml : An ZK spec file, this file defined forge components

/web/: An ZK spec folder, file referenced in lang-addon.xml are relative to this folder.

/build/ : class folder for ant build, in build.xml also copy files in /archive , and after that, this folder is jared in to atticZKForge.jar

/lib/ : ZK library folder

/src/ : source folder

build.xml : an ant build file, this file compile java, copy resource and build aticZKForge.jar

 

atticZKForge Archive structure looks like below:


Lang-addon.xml

 

<language-addon>

        <addon-name>AtticZKForge</addon-name>

        <version>

                <version-class>atticcomp.Version</version-class>

                <version-uid>1.0</version-uid>

                <zk-version>2.3.0</zk-version><!-- or later -->

        </version>

        <language-name>xul/html</language-name>

        <javascript-module name="atticz.attic" version="1.070426.008"/>

        <zscript>

        import atticcomp.*;

        </zscript>

        <component>

                <component-name>HelloWorld</component-name>

                <component-class>atticcomp.HelloWorld</component-class>

                <mold>

                        <mold-name>default</mold-name>

                        <mold-uri>~./atticcomp/helloworld.dsp</mold-uri>

                </mold>

        </component>          

</language-addon>

 

/addon-name : forge name

/version/version-class : version class for your forge , I don't know actual detail.

/language-name : you language, I always use xul/html

/javascript-module : ZK client engine will load this module in to browser if page use any component that defined in this xml. The string 「atticz.attic」 means load file at 「/web/atticz/attic.js」 in jar file (form class path root actually).

/component/component-name : the component you defined , this is tag name also.

/component/component-class : the component implement class.

/component/mold/mold-name : the component mold name

/component/mold/mold-uri : the component mold template file, component will be displayed use this .dsp file. the String 「~./atticcomp/helloworld.dsp」 means load file at 「/web/atticcomp/helloworld.dsp」 in jar file (form class path root actually).

 

HelloWorld Forge Component

 

HellowWorld.java : Just one attribute – yourName

 

package atticcomp;

import org.zkoss.zk.ui.HtmlBasedComponent;

public class HelloWorld extends HtmlBasedComponent {

    private static final long serialVersionUID = 1L;

    String yourName;

    public String getYourName() {

        return yourName;

    }

    public void setYourName(String yourName) {

        this.yourName = yourName;

    }

}

 

helloworld.dsp : simple output yourName

 

<%@ taglib uri="/WEB-INF/tld/web/core.dsp.tld" prefix="c" %>

<c:set var="self" value="${requestScope.arg.self}"/>

<div id="${self.uuid}"${self.outerAttrs} z.type="atticz.attic.HelloWorld">

    <span>[Hello : ${self.yourName}]</span>

</div>

 

atticz.attic.HelloWorld  in z.type means bind this component by script in atticz.attic module's zhHelloWorld object.

I don't know much detail about this, HaHa~.

 

attic.js / HellowWorld : Do not thing in this component.

 

zkHelloWorld = {};

zkHelloWorld.init = function (cmp) {

};

zkHelloWorld.cleanup = function (cmp) {

};

zkHelloWorld.setAttr = function (elm, name, value) {

    return false;

};

 

Sample file :

 

<?xml version="1.0" encoding="utf-8"?>

<window id="w" title="Woo" style="width:200px" border="normal">

    <HelloWorld yourName="dennis" />

</window>

 

Runtime result :

 


Download project source: Project Source

Trackback URL: http://www.javaworld.com.tw/roller/atticcat/entry/2007_4_26_How_to_write_ZK_Forge_Component
Comments:

[Trackback] A big selling point of the server side component Ajax frameworks like ZK and Echo2 is the ability to leverage a library of components so you can stick to the server side environment and not have to bother with Javascript, CSS, etc. Of course in order f...

Posted by Agile Ajax on April 30, 2007 at 10:33 AM CST #

Hello All,
I'm experiencing problems in downloading project souce - I believe registration is needed for that, but the form is in TW.
Can anyone give me a direct link to this archive or guide me how to register on that forum so I can donwnload it myself ?

Thanks,
Ilya

Posted by Ilya N on May 22, 2007 at 10:05 PM CST #

hi, Ilya
I don't have other space to put my file on,
The file is only 10k bytes. if you give me your mail, I will send it to you.

Posted by atticcat on May 22, 2007 at 10:56 PM CST #

hi atticcat,
here's my mail: ilya.ned@gmail.com

Thanks in advance.

Posted by Ilya N on May 23, 2007 at 02:52 PM CST #

Hey atticcat,

The link to donwload does not work anymore, page not found...
Could you send the source to my e-mail
omadruga at gmail dot com ?

Thankyou,
Madruga

Posted by Madruga on March 29, 2008 at 09:19 AM CST #

Hey,

Don´t bother now.
Google translate help me out, and I was able
to download it.

Thanks anyway.
Madruga

Posted by Madruga on March 31, 2008 at 03:27 AM CST #

OKAY,
I am looking for some space to put my source/project file, maybe I will store it in sourceforge.

Posted by atticcat on April 01, 2008 at 09:09 PM CST #

I changed the source file to sourceforge.

Posted by atticcat on April 01, 2008 at 10:56 PM CST #

Google translate help me out, and I was able

Posted by ugg boots on December 25, 2009 at 10:30 AM CST #

It is my great pleasure to visit your website and to enjoy your excellent post here. I like that very much. I can feel that you paid much attention for

those articles, as all of them make sense and are very useful. Thanks so much for sharing. I can be very

good reader&listenerdiscount ugg boots if you are same searching for

all to be good. Appreciate for your time!
Happy New Year!

Posted by jordan shoes on March 16, 2010 at 04:20 PM CST #

Good read. There is currently quite a lot of information around this subject on the net and some are most defintely better than others. You have caught the detail here just right which makes for a refreshing change – thanks.

Posted by 传奇私服 on July 03, 2010 at 01:17 AM CST #

Hi Webmaster, commenters and everybody else !!! The blog was absolutely fantastic! Lots of great information and inspiration, both of which we all need!Keep 'em coming... you all do such a great job at such Concepts... can't tell you how much I, for one appreciate all you do!

Posted by 传奇私服 on July 16, 2010 at 12:01 AM CST #

Your post is very interesting. Please let me know how to go for your rss

Posted by 传奇私服 on August 02, 2010 at 01:42 PM CST #

You have mention good post above I really enjoy the information. I wish to come again on your site in future
<a href="http://www.iqwlj.com">传奇私服</a>

Posted by 传奇私服 on August 12, 2010 at 02:46 PM CST #

[url=http://www.itunes-gift-card.org]itunes gift card,itunes code[/url]
[url=http://www.highwaytowatches.com]swiss replica watches[/url]
[url=http://www.watches-mens.com]mens watches[/url]

Posted by diana on August 27, 2010 at 02:34 PM CST #

I happen to enter your blog with the help of google search. To my sheer luck I got what I was searching for. Thankx
http://www.iqwcs.com/
http://www.iqwkk.com/
http://www.5kcq.com/
http://www.cc-sf.com/
http://www.aa-sf.com/
http://www.iqwhj.com/
http://www.7kcq.com/
http://www.ee-sf.com/

Posted by 传奇私服 on September 02, 2010 at 07:16 PM CST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed
Copyright (C) 2003, 閣樓貓的五四三 (About Cat)