0

Using Folder Based Themes - not working

asked 2013-11-13 21:37:26 +0800

ansancle gravatar image ansancle
327 9

I have read all the wiki's and smalltalks regarding how to use folder based themes but I cannot get my themes to register or work.

I not only created my own theme using the ztx.bat script but also downloaded the dark demo theme from it's smalltalk project.

I will show my code below, I am trying this with 7.0 EE eval.

My application Root is WebRoot where META-INF and WEB-INF are, I put the theme folder on the same level :

WebRoot
  -> META-INF
  -> WEB-INF
  -> theme
      ->OneViewDefaultTheme
      ->dark

In my zk.xml (full file below)

<library-property>
    <name>org.zkoss.theme.preferred</name>
    <value>OneViewDefaultTheme</value> 
</library-property>

I added the required dsp elements to web.xml (full file below) and in my WebAppInitListener I added the following code :

Themes.register("dark", ThemeOrigin.FOLDER);
Themes.register("OneViewDefaultTheme", ThemeOrigin.FOLDER);

In my home page, in the doAfterCompose I run the following to see what themes are registered :

        System.out.println("Current Theme = " + Themes.getCurrentTheme());
        String[] themes = Themes.getThemes();
        for (int i=0;i<themes.length;i++)
            System.out.println("Theme[" + i + "] = " + themes[i]);

This is what I get for output :

16:06:48,405 INFO  [stdout] (ajp-dhl06-127.0.0.1-8009-1) Current Theme = breeze
16:06:48,424 INFO  [stdout] (ajp-dhl06-127.0.0.1-8009-1) Theme[0] = silvertail
16:06:48,425 INFO  [stdout] (ajp-dhl06-127.0.0.1-8009-1) Theme[1] = breeze
16:06:48,426 INFO  [stdout] (ajp-dhl06-127.0.0.1-8009-1) Theme[2] = sapphire

I have no idea why I cannot get them to register, been trying all day, going over smalltalks and questions, it appears I am doing what I am supposed to do but it's not working.

ZK.XML

    <zk>

    <error-page>
        <exception-type>java.lang.Throwable</exception-type>   
        <location>/windows/error/DHzErrorHandlerOnAjaxRequestWindow.zul</location>   
    </error-page>
    <listener>
        <description>Called when the ZK Desktop is detroyed</description>   
        <listener-class>com.dh.ui.common.desktop.DHzDesktopCleanup</listener-class>
    </listener>

    <listener>
        <description>Called when the ZK Desktop is created</description>    
        <listener-class>com.dh.ui.common.desktop.DHzDesktopInitListener</listener-class>
    </listener>     

    <listener>
        <description>Called when the ZK Desktop is created</description>    
        <listener-class>com.dh.ui.common.session.DHzZKSessionListener</listener-class>
    </listener>     

    <listener>
        <description>Monitor the statistic</description>
        <listener-class>org.zkoss.zk.ui.util.Statistic</listener-class>
    </listener>

    <session-config>
        <device-type>ajax</device-type>   
        <timeout-uri></timeout-uri>   
    </session-config>




        <device-config>
            <device-type>ajax</device-type>
            <embed><![CDATA[
         <script type="text/javascript">             

           function isDHAlive()
           {
             return "dhIsAlive";
           }

         </script>
             ]]></embed>
        </device-config>



    <session-config>
        <session-timeout>-1</session-timeout>
        <!-- <timeout-uri>/windows/DHzHomeWindow.zul</timeout-uri>    
        <timer-keep-alive>true</timer-keep-alive>
        <timeout-message>Session timeout. Please reload.</timeout-message> -->
    </session-config>   

  <language-config>
    <addon-uri>/WEB-INF/lang-addon.xml</addon-uri>
  </language-config>    


    <!-- Supposedly this will make it faster, we could define fade, dropdown, etc... here -->
    <preference>
        <name>org.zkoss.zul.Window.defaultActionOnShow</name>
        <value></value>
    </preference>

<!--  Digital Home System Configuration Name Value Pairs -->


    <!--  ID's For PointInstances -->     

    <system-property>
        <name>ipadStyleSheet</name>    
        <value>/stylesheets/dhIpadStyleSheet.css</value>    
    </system-property> 
    <system-property>
        <name>desktopStyleSheet</name>    
        <value>/stylesheets/dhDesktopStyleSheet.css</value>    
    </system-property> 

<library-property>
    <name>org.zkoss.theme.preferred</name>
    <value>OneViewDefaultTheme</value> 
</library-property> 

    <library-property>
        <name>org.zkoss.zul.theme.fontFamilyT</name>
        <value>Georgia</value>
    </library-property>     
    <library-property>
        <name>org.zkoss.zul.theme.fontFamilyC</name>
        <value>Georgia</value>
    </library-property> 
    <library-property>
        <name>org.zkoss.zul.Button.mold</name>
        <value>trendy</value>
    </library-property>

    <!-- UI Properties -->
    <system-property>
        <name>getUserFromCookies</name>    <!--True will get userId from cookies, false forces login page -->
        <value>true</value>    
    </system-property>      

    <!--  The volume that the tuner will default to -->
    <system-property>
        <name>tunerDefaultVolume</name>    
        <value>25</value>    
    </system-property>    


    <!-- Keep using the ZK event processing thread - needed for upgrade to 5.0 -->
    <system-config>
        <disable-event-thread>false</disable-event-thread>
    <!--    <id-generator-class>com.dh.ui.common.util.DHzIDGenerator</id-generator-class> --><!-- For Testing uncomment out this line -->
    </system-config>

    <!-- In 3.6 this was the detault include mode, for 5.0 it's auto, once everything is working
         revisit this to see if it breaks anything if it goes to "auto" -->
    <library-property>
        <name>org.zkoss.zul.include.mode</name>
        <value>auto</value>
    </library-property>

</zk>

WEB.XML

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 

    <error-page>
        <exception-type>java.lang.Throwable</exception-type>   
        <location>/windows/DHzHomeWindow.zul</location>   
    </error-page>
    <description><![CDATA[DH Ipad UI]]></description>
    <display-name>DH Ipad UI</display-name>
    <listener>
        <description>ZK listener for cleanup when a session is destroyed</description>
        <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
    </listener>

    <servlet>
        <description>ZK loader for evaluating ZUML pages</description>
        <servlet-name>zkLoader</servlet-name>
        <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
        <!--
            Must. Specifies URI of the update engine (DHtmlUpdateServlet). It
            must be the same as <url-pattern> for the update engine.
        -->
        <init-param>
            <param-name>update-uri</param-name>
            <param-value>/zkau</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup><!-- MUST -->
    </servlet>
    <servlet>
        <servlet-name>dspLoader</servlet-name>
        <servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>dspLoader</servlet-name>
        <url-pattern>*.dsp</url-pattern>
    </servlet-mapping>    

    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>*.zul</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>zkLoader</servlet-name>
        <url-pattern>*.zhtml</url-pattern>
    </servlet-mapping>
    <servlet>
        <description>The asynchronous update engine for ZK</description>
        <servlet-name>auEngine</servlet-name>
        <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>auEngine</servlet-name>
        <url-pattern>/zkau/*</url-pattern>
    </servlet-mapping>
     <!-- //// -->

     <!-- MIME mapping -->
    <mime-mapping>
        <extension>gif</extension>
        <mime-type>image/gif</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>html</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>htm</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>jad</extension>
        <mime-type>text/vnd.sun.j2me.app-descriptor</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>jpeg</extension>
        <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>jpg</extension>
        <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>js</extension>
        <mime-type>application/x-javascript</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>png</extension>
        <mime-type>image/png</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>txt</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>xml</extension>
        <mime-type>text/xml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>zhtml</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>zul</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>

    <welcome-file-list>
            <welcome-file>/windows/DHzHomeWindow.zul</welcome-file> 
    </welcome-file-list>


</web-app>

Here is my packaging file :

 <?xml version="1.0" encoding="UTF-8"?>
<project name="Packaging Generator" default="_packaging_generation_">
    <target name="_packaging_generation_" depends="buildinfo,N65540,N65609" />
    <target name="N65540" description="com.dh.ui.ipad.web.war">
        <jar destfile="com.dh.ui.ipad.web.war">
            <zipfileset dir="WebRoot/theme" prefix="theme">
                <include name="*" />
            </zipfileset>
            <zipfileset dir="WebRoot/WEB-INF" prefix="WEB-INF">
                <include name="web.xml" />
            </zipfileset>
            <zipfileset dir="WebRoot/WEB-INF" prefix="WEB-INF">
                <include name="zk.xml" />
            </zipfileset>
            <zipfileset dir="WebRoot/WEB-INF" prefix="WEB-INF">
                <include name="lang-addon.xml" />
            </zipfileset>
            <zipfileset dir="WebRoot/META-INF" prefix="META-INF">
                <include name="project.properties" />
            </zipfileset>
            <zipfileset dir="WebRoot/zul" />
            <zipfileset dir="WebRoot/WEB-INF/classes" prefix="WEB-INF/classes" />
            <zipfileset dir="../com.dh.ui.common/lib/zk" prefix="WEB-INF/lib" />
            <zipfileset dir="../com.dh.ui.common/WebRoot/zul" />
            <zipfileset dir="../com.dh.ui.common/WebRoot/WEB-INF/classes" prefix="WEB-INF/classes" includes="**/*.class" />
            <zipfileset dir="../com.dh.ui.common.audio/WebRoot/zul" />
            <zipfileset dir="../com.dh.ui.common.audio/WebRoot/WEB-INF/classes" prefix="WEB-INF/classes" includes="**/*.class" />
        </jar>
    </target>
    <target name="N65609" description="com.dh.ui.ipad.app.ear">
        <jar destfile="com.dh.ui.ipad.app.ear">
            <zipfileset dir="WebRoot/META-INF" prefix="META-INF">
                <include name="application.xml" />
            </zipfileset>
            <zipfileset dir="WebRoot/META-INF" prefix="META-INF">
                <include name="jboss-deployment-structure.xml" />
            </zipfileset>
            <zipfileset dir=".">
                <include name="com.dh.ui.ipad.web.war" />
            </zipfileset>
        </jar>
    </target>
    <target name="buildinfo">
        <property environment="env"/>
        <condition property="svnTagVersion" value="${env.SVN_TAG}" else="development">
            <isset property="env.SVN_TAG" />
        </condition>

        <exec executable="svnversion" outputproperty="svnversion"/>
        <exec executable="whoami" outputproperty="whoami"/>
        <exec executable="uname" outputproperty="buildsystem"><arg value="-a"/></exec>

        <propertyfile file="WebRoot/META-INF/project.properties"
            comment="This file is automatically generated - DO NOT EDIT">
            <entry key="svnVersion" value="${svnversion}"/>
            <entry key="svnTagVersion" value="${svnTagVersion}"/>
            <entry key="builder" value="${whoami}"/>
            <entry key="system" value="${buildsystem}"/>
        </propertyfile>
    </target>
</project>
delete flag offensive retag edit

Comments

4 Answers

Sort by ยป oldest newest most voted
0

answered 2013-11-14 00:55:58 +0800

cor3000 gravatar image cor3000
6280 2 7

Hi,

thanks for all the details... I hope I didn't miss the anything - I just could not see your WebAppInitListener being registered anywhere in zk.xml as described here (3rd paragraph).

maybe also put a log statement into it to see it actually executes and the themes become available.

Regards,

Robert

link publish delete flag offensive edit
0

answered 2013-11-14 01:37:43 +0800

ansancle gravatar image ansancle
327 9

The WebAppInitListener is being called as I have a break in there, but your right, the listener is not defined in that zk.xml - very strange. We are deploying several applications to jboss at once, I will talk with the packaging person tomorrow. Maybe I need to move the themes to one of the other applications instead - seems strange to me but would explain why it's not working.

Do you see anything else I may be doing wrong?

Thanks! Andy

link publish delete flag offensive edit

Comments

It seems strange, that the listener is called, but if it is as you say can you check it is actually registering it for the same WebApp instance? e.g.output the same log statements, as you do in "doAfterCompose" and log the WebApp instance or the context name at the same time.

cor3000 ( 2013-11-14 03:08:35 +0800 )edit

additionally you can check that the ThemeRegistry is the same ... by calling ThemeFns.getThemeRegistry(), or put a breakpoint in DesktopThemeRegistry.deregister() to check no one is deregistering your themes

cor3000 ( 2013-11-14 03:16:06 +0800 )edit

almost forgot to mention, did you try this with ZK 6.5.x since there have been some major changes between ZK6.5 and 7 about themes... so maybe your theme is not compatible with ZK7...?

cor3000 ( 2013-11-14 09:30:41 +0800 )edit
0

answered 2013-11-14 13:26:07 +0800

ansancle gravatar image ansancle
327 9

Thanks so much for your help. I ended up getting the themes to register and show up, but I had to move where I was registering them from the WebAppInitListener to my home page doAfterCompose. That is not where I will leave the registration but they registered correctly and switched to the one I wanted - so it's huge progress.

The other issue I had was in my packaging.xml file - the include name="*" was preventing the contents of the theme directories from being packaged. So in the deployed .war file the directory names were there but no contents. So it looks like I am moving forward!

<zipfileset dir="WebRoot/theme" prefix="theme">
    <include name="*" />
</zipfileset>
link publish delete flag offensive edit
0

answered 2013-11-15 00:30:12 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2013-11-15 00:32:25 +0800

yes when it is an ant build file... it should be **/* to recursively pick up all subfolders and their content.

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-13 21:37:26 +0800

Seen: 45 times

Last updated: Nov 15 '13

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