Component Properties"

From Documentation
m (remove empty version history (via JWB))
 
(7 intermediate revisions by the same user not shown)
Line 10: Line 10:
  
 
==Page-wide Initialization==
 
==Page-wide Initialization==
Suppose we want to assign <tt>normal</tt> to the border property (<javadoc method="setBorder(java.lang.String)">org.zkoss.zul.Window</javadoc>) of all windows in a ZUML document, then we could use [[ZUML Reference/ZUML/Processing Instructions/component|the component directive]] as follows.
+
Suppose we want to assign <code>normal</code> to the border property (<javadoc method="setBorder(java.lang.String)">org.zkoss.zul.Window</javadoc>) of all windows in a ZUML document, then we could use [[ZUML Reference/ZUML/Processing Instructions/component|the component directive]] as follows.
  
 
<source lang="xml">
 
<source lang="xml">
Line 19: Line 19:
 
==Application-wide Initialization==
 
==Application-wide Initialization==
  
If you prefer to have the same initial value for all ZUML documents, you could specify it in [[ZK Client-side Reference/Language Definition|a language addon]]. For example, we could prepare a file called <tt>WEB-INF/lang-addon.xml</tt> with the following content:
+
If you prefer to have the same initial value for all ZUML documents, you could specify it in [[ZK Client-side Reference/Language Definition|a language addon]]. For example, we could prepare a file called <code>WEB-INF/lang-addon.xml</code> with the following content:
  
 
<source lang="xml">
 
<source lang="xml">
 
<language-addon>
 
<language-addon>
 
<addon-name>myapp</addon-name>
 
<addon-name>myapp</addon-name>
 +
<language-name>xul/html</language-name>
 
<component>
 
<component>
 
<component-name>window</component-name>
 
<component-name>window</component-name>
Line 35: Line 36:
 
</source>
 
</source>
  
Then, we could specify this file by adding the following content to <tt>WEB-INF/zk.xml</tt>:
+
Then, we could specify this file by adding the following content to <code>WEB-INF/zk.xml</code>:
  
 
<source lang="xml">
 
<source lang="xml">
Line 47: Line 48:
 
=Molds=
 
=Molds=
  
A mold is yet another property (<javadoc method="setMold(java.lang.String)" type="interface">org.zkoss.zk.ui.Component</javadoc>), 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 <tt>''ClassName''.mold</tt>. For example, if you would like to specify <tt>trendy</tt> as the initial mold of a button, then you could add the following to <tt>WEB-INF/zk.xml</tt>:
+
A mold is yet another property (<javadoc method="setMold(java.lang.String)" type="interface">org.zkoss.zk.ui.Component</javadoc>), 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 <code>''ClassName''.mold</code>. For example, if you would like to specify <code>trendy</code> as the initial mold of a button, then you could add the following to <code>WEB-INF/zk.xml</code>:
  
 
<source lang="xml">
 
<source lang="xml">
Line 57: Line 58:
  
 
=Attributes=
 
=Attributes=
Like properties, you could assign the initial value of an attribute for a given component in the whole application.
+
Like properties, you could assign an attribute's initial value for a given component in the whole application (like calling [https://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/ext/Scope.html#setAttribute(java.lang.String,%20java.lang.Object,%20boolean) Component.setAttribute()]).
  
 
Notice that 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 that 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).
Line 72: Line 73:
 
<language-addon>
 
<language-addon>
 
<addon-name>myapp</addon-name>
 
<addon-name>myapp</addon-name>
 +
<language-name>xul/html</language-name>
 
<component>
 
<component>
 
<component-name>panel</component-name>
 
<component-name>panel</component-name>
 
<extends>panel</extends>
 
<extends>panel</extends>
 
<custom-attribute>
 
<custom-attribute>
<attribute-name>any.attribute</attribute-name>
+
<attribute-name>any.attribute.name</attribute-name>
<attribute-value>any value</attribute-value>
+
<attribute-value>any.value</attribute-value>
 
</custom-attribute>
 
</custom-attribute>
 
</component>
 
</component>
Line 83: Line 85:
 
</source>
 
</source>
  
=Version History=
+
 
{{LastUpdated}}
 
{| border='1px' | width="100%"
 
! Version !! Date !! Content
 
|-
 
| &nbsp;
 
| &nbsp;
 
| &nbsp;
 
|}
 
  
 
{{ZKDevelopersReferencePageFooter}}
 
{{ZKDevelopersReferencePageFooter}}

Latest revision as of 04:33, 5 February 2024


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 that 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-wide 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>
	<language-name>xul/html</language-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 assign an attribute's initial value for a given component in the whole application (like calling Component.setAttribute()).

Notice that 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

Unlike the initial value of a property, there is no way to specify the initial value of a custom attribute in a ZUML document.

Application-wide Initialization

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

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




Last Update : 2024/02/05

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