The preference Element"

From Documentation
Line 1: Line 1:
 
 
<source lang="xml" >
 
<source lang="xml" >
 
  <preference>
 
  <preference>
Line 9: Line 8:
 
Specify a preference with the <tt>preference</tt> element depicted above. The name and value are application specific and you can specify whatever value you like. Mupltie To avoid name conflict, it is suggested to prefix the name with your domain name, such as <tt>com.friend.some.another</tt>.
 
Specify a preference with the <tt>preference</tt> element depicted above. The name and value are application specific and you can specify whatever value you like. Mupltie To avoid name conflict, it is suggested to prefix the name with your domain name, such as <tt>com.friend.some.another</tt>.
  
The preferences are application-level. They are shared by a single ZK application (<javadoc>org.zkoss.zk.ui.WebApp</javadoc>).
+
The preferences are application-level. They are shared by a single ZK application (<javadoc type="interface">org.zkoss.zk.ui.WebApp</javadoc>).
  
 
They can then be retrieved back by calling the <tt>getPreference</tt> method of the <javadoc>org.zkoss.zk.ui.util.Configuration</javadoc> class. Notice that each Web application has one configuration, which can be found by use of <tt>getConfiguration</tt> method of the <javadoc type="interface">org.zkoss.zk.ui.WebApp</javadoc> interface.
 
They can then be retrieved back by calling the <tt>getPreference</tt> method of the <javadoc>org.zkoss.zk.ui.util.Configuration</javadoc> class. Notice that each Web application has one configuration, which can be found by use of <tt>getConfiguration</tt> method of the <javadoc type="interface">org.zkoss.zk.ui.WebApp</javadoc> interface.

Revision as of 06:40, 9 July 2010

 <preference>
     <name>''any name''</name>
     <value>''any value''</value>
 </preference>

Specify a preference with the preference element depicted above. The name and value are application specific and you can specify whatever value you like. Mupltie To avoid name conflict, it is suggested to prefix the name with your domain name, such as com.friend.some.another.

The preferences are application-level. They are shared by a single ZK application (WebApp).

They can then be retrieved back by calling the getPreference method of the Configuration class. Notice that each Web application has one configuration, which can be found by use of getConfiguration method of the WebApp interface.

 String value = webApp.getConfiguration().getPreference("org.zkoss.name", null);
 if (value != null) {
     ...
 }