ZK+组件jar静态资源

ZK + component jar static resources

我正在使用ZK框架,并创建了一个自定义组件的maven项目。

我正在尝试按照此页面上的简要概述为项目(对于没有 javascript 的组件)包含静态 CSS:

http://books.zkoss.org/wiki/ZK_Component_Development_Essentials/Packing_as_a_Jar

zk如何知道将项目包含在ZK WEB项目中时生成的CSS?目前我的组件项目的资源目录如下所示:

web
    foo
         bar
            css
               zk.wcs
               macro.css.dsp
               other.css.dsp
            less
               macro.less
               other.less  

我的zk.wcs:

<css language="xul/html">
    <stylesheet href="~./foo/bar/css/macro.css.dsp"/>
    <stylesheet href="~./foo/bar/css/primitive.css.dsp"/>
</css>

我在 macro.css.dsp 中的样式在我的 web zk 项目中使用组件项目时没有应用但是...

您可以在 lang-addon.xml 中包含 css:

<!-- define a component -->
<component>
    <!-- the tag name of this component
        required,
        must be unique -->
    <component-name>codemirror</component-name>
    <!-- fully-qualified java class name at server side
        required for a new component that not extends another component -->
    <component-class>org.sinnlabs.zk.ui.CodeMirror</component-class>
    <!-- widget class, 'org.sinnlabs.zk.ui.CodeMirror' also specify the
        package of widget class 'org.sinnlabs.zk.ui'
        required for a new component that not extends another component -->

    <widget-class>org.sinnlabs.zk.ui.CodeMirrorWidget</widget-class>
    <!-- mold
        required for a new component that not extends another component
        or has self widget-class

        a mold denotes the files that to render and style this comopnent -->
    <mold>
        <!-- default mold is required -->
        <mold-name>default</mold-name>
        <!-- relative path based on widget-class' path
            (web/js/org/sinnlabs/zk/ui/)

            where codemirrorwidget.js (required) contains a function that
            will render the html of the comopnent. -->
        <mold-uri>mold/codemirrorwidget.js</mold-uri>
        <css-uri>css/codemirror.css</css-uri>
    </mold>
</component>

zk.load 将加载您的 css 样式。