-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
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
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!
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. :)
Asked: 2011-08-04 04:52:03 +0800
Seen: 611 times
Last updated: Aug 04 '11