0

Static resources in Component Jar

asked 2015-01-19 04:28:42 +0800

JustinFrost gravatar image JustinFrost
139 1 6

I have created a maven project of custom components, this jar is included as a dependancy in my ZK Web project.

I am trying to include static CSS for the project (for components with no javascript) as per the brief outline on this page:

http://books.zkoss.org/wiki/ZKComponentDevelopmentEssentials/PackingasaJar

How does zk know to include the CSS generated when the project is included in a ZK WEB project ? Currently my resources directory of my component project looks like this:

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

My zk.wcs :

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

My styles in macro.css.dsp are not applied when using the component project in my web zk project however...

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-01-22 13:24:09 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2015-01-22 13:37:13 +0800

I'm now on place.

One of my the jars have the following structure where i set up the css path:

src/main/resources/metainfo/zk/lang-addon.xml

lang-addon.xml

<?xml version="1.0" encoding="UTF-8"?>

<language-addon>
    <!-- The name of this addon. It must be unique -->
    <addon-name>zkboost-theme-cyborg</addon-name>

    <!-- Specifies what other addon this depends -->
    <depends>zul,zkmax</depends>

    <!-- Which language this addon will be added to -->
    <language-name>xul/html</language-name>

    <version>
        <zk-version>7.0.0</zk-version><!-- or later -->
    </version>

    <!-- ##################################################################### -->
    <!-- Define this paths dependent from the files packed in the theme jar file -->
    <!-- The order of this files is important because we override zk css styles -->
    <!-- ##################################################################### -->

    <!-- 1. Path to ZK css.dsp -->
    <stylesheet href="~./cyborg/zul/css/norm.css.dsp" type="text/css" media="screen" />
    <!-- 2. Path to Font-Awesome css.dsp -->
    <stylesheet href="~./cyborg/css/fontawesome.css.dsp" type="text/css" media="screen" />
    <!-- 3. Path to Bootstrap + Zk customized css.dsp -->
    <stylesheet href="~./cyborg/css/cyborg.css.dsp" type="text/css" media="screen" />

    <!-- 4. Path to Bootstrap javascript library -->
    <javascript src="~./cyborg/less/bootstrap/js/bootstrap.min.js" type="text/javascript" charset="UTF-8" /> 


</language-addon>

For the exact path you must open the generated jar and look where the used files are. These path should be in the lang-addon.xml

As you said it's a separate jar than you must let ZK know this. For searching a file/class/resource/zul... in a sperarate jar file you should use "~./" in front of your path. It tells ZK to make a classpath scanning for the file.

best Stephan

link publish delete flag offensive edit

Comments

Awsome, thanks Stephan that worked nicely. I knew it had to be something simple in the end. Thanks.

JustinFrost ( 2015-01-23 00:19:19 +0800 )edit
0

answered 2015-01-21 17:48:53 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Sorry i'm not at my machine. put a langaddon.xml file in metainf folder in your jar project. Place there the CSS path.

link publish delete flag offensive edit

Comments

I have a langaddon.xml file for defining my components, most components have molds and therefore css is specified there. The macro components without molds are what I am having trouble with, how do I add css for these which will be included when the project is added as a dependency to a UI project.

JustinFrost ( 2015-01-21 23:28:16 +0800 )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: 2015-01-19 04:28:42 +0800

Seen: 51 times

Last updated: Jan 22 '15

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