0

How can I easily create a new mold for a component (i.e. a popover from a popup component)

asked 2011-08-04 04:52:03 +0800

rogerflattin gravatar image rogerflattin
6

updated 2011-08-04 06:49:18 +0800

I've used previous version of ZK before and have no problem creating mold for existing ZK components. We are evaluating the ZK framework for an important product but we encounter difficulties creating mold.

The process seems much more complicated with the JavaScript frontend than before and I cannot solve my problems. I've started by activating the /WEB-INF/lang-addon.xml file in where I declare a simple mold:


<component>
<component-name>popover</component-name>
<component-class>org.zkoss.zul.Popup<</component-class>
<mold>
<mold-name>popover</mold-name>
<widget-class>zul.wgt.Popup</widget-class>
<mold-uri>/mold/popover.src.js</mold-uri>
</mold>
</component>

But when I launch the Tomcat server and load the page, ZK doesn't seem to find the mold. It displays an error:

/mold/popover.src.js not found

I can't find a documentation that explains how to simply add a mold to an existing component.

What's wrong with this approach? Where does ZK search for mold file? I create a mold directory in my ZK application and put the mold file in it (webapps/MyZKApp/mold/popover.src.js) but the mold file is not found by ZK? How can I log the file path in which ZK finds it's file?

What's strange is that if I monitor files that are opened on the machine (using DTrace) I've see no trace of a popover.src.js file. Does this mean that ZK in only capable of finding a mold file in its jar files?
Thanks in advance

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-08-04 14:13:13 +0800

TonyQ gravatar image TonyQ
642
https://www.masterbranch....

updated 2011-08-04 14:13:45 +0800

There's multiple questions in this and take some time to explain details, let me try to answer you one by one.

1.ZK could extend it easily , no problem.

2.why the path is not fetching or not working ,

For minimize the js file loading , ZK will package all the smaller javascript file in to a WPD file when user try to request it ,
so it have its spec for the js file path,and by default we will load the .js file from the resource in classpath .

So you won't find a request to the script file directly , it's already merged in the WPD.


------------------------------------------

Then let's talk about how to do this:

Usually we will suggest to separate it into different project, and use the component as a jar file,
(reference http://books.zkoss.org/wiki/ZK%20Client-side%20Reference/Component%20Development )
but here I assume you just want to create a mold directly in the WEB application.


The easiest way is to create a lang-addon.xml in the WEB-INF with mold definitation,
and then place the popover.src.js to the right place.

You have two choice to handle the popover.src.js

1. To place it to your source folder
For example , it might be "src/web/js/zul/wgt/mold/popover.src.js" (the source is the source folder) ,
and it should be in a jar file (not required to be a ZK one) or WEB-INF/classes/web/js/zul/wgt/mold/popover.src.js in the finally result.

2. using class-web-resource configurations (my suggested way)
http://books.zkoss.org/wiki/ZK_Configuration_Reference/zk.xml/The_Library_Properties/org.zkoss.web.util.resource.dir

when you setup

<library-property>
    <name>org.zkoss.web.util.resource.dir</name>
    <value>/WEB-INF/cwr</value>
</library-property>

you could place the popover.src.js to

WEB-INF/cwr/js/zul/wgt/mold/popover.src.js

link publish delete flag offensive edit

answered 2011-08-04 15:56:58 +0800

rogerflattin gravatar image rogerflattin
6

updated 2011-08-04 16:04:59 +0800

Thank you very for having taking time to respond to my questions. It contains a lot of interesting information and now everything works!

Thank you very much!

link publish delete flag offensive edit

answered 2011-08-04 18:24:09 +0800

TonyQ gravatar image TonyQ
642
https://www.masterbranch....

It's glad to know that. :)

Please feel free to ask more questions , and we will also try to enhance the document with more details of widget customization. :)

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-08-04 04:52:03 +0800

Seen: 611 times

Last updated: Aug 04 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More