Dinamically change css value based on enviroment

asked 2021-02-24 22:04:30 +0800

ziobleed gravatar image ziobleed
3 2

Hi all,

i'm using zk with MVC approach.

i've some web projects that doesnt use a theme for styling but a series of css.dsp file like


In this file there is a css property that determines the background color of certain zk elements.

I want that my app use a specific background color based on which enviroment is deploied on:

ie if the web app is deploied in a production enviroment the color must be green, if is deploied in test the color must be blue.

Ideally the enviroment and the color will be discovered reading from a db or from a properties file.

How can i reach that is an easy way?


delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted

answered 2021-02-25 18:12:55 +0800

cor3000 gravatar image cor3000
5833 2 7
ZK Team

when using a dsp file you can read system/library properties using the taglib function ${c:property('SOME_PROP_NAME')}


the example DSP shows how to include the core taglib https://www.zkoss.org/wiki/ZKDeveloper'sReference/Supporting_Utilities/DSP

a dynamic style might look like this, outputting the property MY_ENV_COLOR:

<%@ taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" %>
.body {
  background-color: ${c:property('MY_ENV_COLOR')};
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




Asked: 2021-02-24 22:04:30 +0800

Seen: 6 times

Last updated: Feb 25

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