ZK +组件jar静态资源

时间:2015-01-19 04:24:36

标签: zk

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

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

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>

我在web zk项目中使用组件项目时,不会应用我在macro.css.dsp中的样式...

1 个答案:

答案 0 :(得分:1)

您可以在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样式。