0

New mold for existing component

asked 2013-11-20 10:21:52 +0800

bobo gravatar image bobo
24

I would like to create a new mold for the Datebox component. Is this possible without creating a new widget that extends zul.db.Datebox?

I have tried creating a mold by adding mymold.js to /web/js/zul/db/mold/mymold.js and registering it in lang-addon.xml with the following:

<component>
<component-name>datebox</component-name>
<component-class>org.zkoss.zul.Datebox</component-class>
<extends>datebox</extends>
<mold>
<mold-name>mymold</mold-name>
<mold-uri>mold/mymold.js</mold-uri>
</mold>
</component>

But when I use the component with mold="mymold" I get an error saying "Mold mymold not found in zul.db.Datebox". If I use a mold name not defined (for example mold="unknownmold") I get an error saying "org.zkoss.zk.ui.UiException: Unknown mold: unknownmold.; allowed: [mymold, default, rounded]".

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-11-27 11:31:23 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2013-11-27 11:33:32 +0800

Hi Bobo,

your example looks alright, I did almost the same and it worked, so it might be that your mold-JS file is not available on the classpath during runtime.

<component>
    <component-name>datebox</component-name>
    <!-- no need to redefine the Component class -->
    <extends>datebox</extends>
    <mold>
        <mold-name>mymold</mold-name>
        <mold-uri>mold/datebox-my.js</mold-uri>
        <css-uri>css/calendar.css.dsp</css-uri>
    </mold>     
</component>

and I put my mold script into my project's classpath (just make sure it is somewhere in the classpath)

/src/main/java/web/js/zul/db/mold/datebox-my.js or /WEB-INF/classes/web/js/zul/db/mold/datebox-my.js

function(out) {
    out.push("hello!");
    zul.inp.ComboWidget.$redraw.apply(this, arguments);
}

Please let me know if this does not solve your issue.

Regards,

Robert

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2013-11-20 10:21:52 +0800

Seen: 61 times

Last updated: Nov 27 '13

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