ZK Class Concept"

From Documentation
m
m
Line 1: Line 1:
 
{{ZKStyleGuidePageHeader}}
 
{{ZKStyleGuidePageHeader}}
  
ZK Class concept was introduced in ZK 3.6.0 version, it is a naming pattern, it appends some regular patterns for client action (please refer to the next section) , like click, focus, mouse-over, mouse-out, and so on.
+
ZK Class (aka., zclass) is a naming pattern. It appends a particular pattern for particular user's activity, such as click, focus, mouse-over, mouse-out, and so on. For example, when a user moves the mouse over a button, additional CSS class will be added automatically to  the button. Since ZK Style Class of abutton is <tt>z-button</tt>, the CSS class will be <tt>z-button z-button-over</tt> when the mouse is over it. Similarly, if the button gains the focus, the CSS class will become <tt>z-button z-button-focus</tt>. Thus, we could customize a specific component for a particular scenario easily.
  
 +
ZK Class is also used to distinguish different molds of components, and even to provide totally different look for the same component in the same mold.
  
ZK Class is also used for changing mold of components, and can be used to separate the two same components with different theme without any conflict. For example, there is a Button component and its ZK Class is called “z-button”, when user mouse is over the button, the ZK Class of the component will be appended with “-over” by ZK client engine, then the full ZK Class will be “z-button-over” so that we can easily customize a specific component theme for special purpose.
+
There are three different ways to change the style of ZK components:
  
 +
# Change sclass (<javadoc method="setSclass(java.lang.String)" type="interface">org.zkoss.zk.ui.Component</javadoc>)
 +
# Change zclass (<javadoc method="setZclass(java.lang.String)" type="interface">org.zkoss.zk.ui.Component</javadoc>)
 +
# Overwrite CSS rule (of the predefined name)
  
There are three different ways to change the style of ZK components as follows. The figure 1 shows where the Sclass and Zclass should be located, the red box means the Sclass will be appended to the root DOM tree of the component, and the green box means the Zclass will be treated as a prefix temp.
+
The relationship of sclass and zclass is shown below. The sclass, the red box below, will be added to the CSS class of the root DOM element of the component, and the zclass, the green box below, will be used as a prefix for the naming the CSS class of the child DOM elements.
  
 
{{ZKStyleGuideHeadingToc
 
{{ZKStyleGuideHeadingToc

Revision as of 05:11, 8 April 2011

ZK Class Concept



ZK Class (aka., zclass) is a naming pattern. It appends a particular pattern for particular user's activity, such as click, focus, mouse-over, mouse-out, and so on. For example, when a user moves the mouse over a button, additional CSS class will be added automatically to the button. Since ZK Style Class of abutton is z-button, the CSS class will be z-button z-button-over when the mouse is over it. Similarly, if the button gains the focus, the CSS class will become z-button z-button-focus. Thus, we could customize a specific component for a particular scenario easily.

ZK Class is also used to distinguish different molds of components, and even to provide totally different look for the same component in the same mold.

There are three different ways to change the style of ZK components:

  1. Change sclass (Component.setSclass(String))
  2. Change zclass (Component.setZclass(String))
  3. Overwrite CSS rule (of the predefined name)

The relationship of sclass and zclass is shown below. The sclass, the red box below, will be added to the CSS class of the root DOM element of the component, and the zclass, the green box below, will be used as a prefix for the naming the CSS class of the child DOM elements.





Last Update : 2011/04/08

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.