0

How to Dynamically apply our own custom themes in zk 8.5

asked 2017-11-23 21:16:35 +0800

AmanS gravatar image AmanS
1

I have made my own custom theme.

As i set this theme in zk.xml

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

the theme is being applied ,but as i will be creating My own multiple custom themes how do i choose it programitacally?

delete flag offensive retag edit

5 Answers

Sort by ยป oldest newest most voted
0

answered 2017-11-27 14:13:44 +0800

AmanS gravatar image AmanS
1

Thanks Robert For the example will try using it.

link publish delete flag offensive edit
0

answered 2017-11-30 18:54:51 +0800

knz237 gravatar image knz237
1

@cor3000 -- did you try the session based theme resolver approach?

The demo you provided is working in composer but I'm trying to implement it based on session. The code provided in the demo example on the link you provided for ThemeResolver - request.getSession(); does not return a org.zkoss.zk.ui.Session; but an HttpSession instead.

link publish delete flag offensive edit

Comments

yes that's absolutely expected... is there any problem with setting and getting attributes from a HttpSession object? Besides the ZK-Session will delegate attributes into the HttpSession anyway so both objects share the same session attributes... did you try it then? was there a problem?

cor3000 ( 2017-11-30 20:19:03 +0800 )edit
0

answered 2017-11-24 09:02:51 +0800

cor3000 gravatar image cor3000
6280 2 7

Hi Aman,

The available methods and a way to customize the theme resolution are described in our documentation on Switching Themes.

I hope this contains the information you are looking for and this will also work with custom theme names.

Robert

link publish delete flag offensive edit
0

answered 2017-11-24 13:56:06 +0800

AmanS gravatar image AmanS
1

Hi Robert,

I have already tried with the link of (Switching Themes) But it is not working.By Directly Setting It in Zk.xml my theme is working but not dynamically. Stuck for almost 3 weeks :(.

link publish delete flag offensive edit

Comments

saying "it's not working" doesn't really help since I can say the same "it's working for me" without giving you any hint... can you explain how it fails? what kinds of css URLs are sent to the server? what's in the content of those responses? did you try the session based theme resolver approach?

cor3000 ( 2017-11-24 14:42:28 +0800 )edit
0

answered 2017-11-24 14:51:30 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2017-11-24 16:19:50 +0800

here a working example how to switch between themes: http://zkfiddle.org/sample/pcqglb/1-switch-theme-dynamically

Are you doing anything differently?

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
2 followers

RSS

Stats

Asked: 2017-11-23 21:16:35 +0800

Seen: 45 times

Last updated: Nov 30 '17

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