Component Properties"

From Documentation
Line 61: Line 61:
 
Notice the initial values are applicable only to the component instantiated by ZK Loaders. It has no effect if you instantiate it in pure Java (unless you invoke <javadoc method="applyProperties()" type="interface">org.zkoss.zk.ui.Component</javadoc> after instantiating a component).
 
Notice the initial values are applicable only to the component instantiated by ZK Loaders. It has no effect if you instantiate it in pure Java (unless you invoke <javadoc method="applyProperties()" type="interface">org.zkoss.zk.ui.Component</javadoc> after instantiating a component).
 
==Page-wide Initialization==
 
==Page-wide Initialization==
==Application-wid Initialization==
+
==Application-wide Initialization==
 +
 
 +
Similar to customizing the initial value of a property, you could specify the following in [[ZK Developer's Reference/Language Definition|a language addon]].
 +
 
 +
<source lang="xml">
 +
<language-addon>
 +
<addon-name>myapp</addon-name>
 +
<component>
 +
<component-name>panel</component-name>
 +
<extends>panel</extends>
 +
<custom-attribute>
 +
<attribute-name>any.attribute</attribute-name>
 +
<attribute-value>any value</attribute-value>
 +
</custom-attribute>
 +
</component>
 +
</language-addon>
 +
</source>
 +
 
 
=Version History=
 
=Version History=
 
{{LastUpdated}}
 
{{LastUpdated}}

Revision as of 06:46, 30 November 2010


Component Properties


With component definitions, we could specify the initial values for the properties, attributes and annotations of a component.

Properties

Depending on the requirement, you could change the initial value of a property for a particular ZUML document, or for the whole application.

Notice the initial values are applicable only to the component instantiated by ZK Loaders. It has no effect if you instantiate it in pure Java (unless you invoke Component.applyProperties() after instantiating a component).

Page-wide Initialization

Suppose we want to assign normal to the border property (Window.setBorder(String)) of all windows in a ZUML document, then we could use the component directive as follows.

<?component name="window" extends="window" border="normal"?>
<window title="Border"/>

Application-wid Initialization

If you prefer to have the same initial value for all ZUML documents, you could specify it in a language addon. For example, we could prepare a file called WEB-INF/lang-addon.xml with the following content:

<language-addon>
	<addon-name>myapp</addon-name>
	<component>
		<component-name>window</component-name>
		<extends>window</extends>
		<property>
			<property-name>border</property-name>
			<property-value>normal</property-value>
		</property>
	</component>
</language-addon>

Then, we could specify this file by adding the following content to WEB-INF/zk.xml:

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

For more information, please refer to ZK Configuration Reference.

Molds

A mold is yet another property (Component.setMold(String)), so you could change the initial value as described in the previous section. However, since it is common to change the value, we allow developers to specify the mold for a given component in a library property. As shown, the library is named as ClassName.mold. For example, if you would like to specify trendy as the initial mold of a button, then you could add the following to WEB-INF/zk.xml:

	<library-property>
		<name>org.zkoss.zul.Button.mold</name>
		<value>trendy</value>
	</library-property>

Attributes

Like properties, you could change the initial value of an attribute for a particular ZUML document, or for the whole application.

Notice the initial values are applicable only to the component instantiated by ZK Loaders. It has no effect if you instantiate it in pure Java (unless you invoke Component.applyProperties() after instantiating a component).

Page-wide Initialization

Application-wide Initialization

Similar to customizing the initial value of a property, you could specify the following in a language addon.

<language-addon>
	<addon-name>myapp</addon-name>
	<component>
		<component-name>panel</component-name>
		<extends>panel</extends>
		<custom-attribute>
			<attribute-name>any.attribute</attribute-name>
			<attribute-value>any value</attribute-value>
		</custom-attribute>
	</component>
</language-addon>

Version History

Last Update : 2010/11/30


Version Date Content
     



Last Update : 2010/11/30

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