CDI"

From Documentation
Line 20: Line 20:
 
</source>
 
</source>
  
Then, we could access it by specifying the variable resolver: <javadoc>org.zkoss.zkplus.cdi.DelegatingVariableResolver</javadoc>, then variables defined by CDI (with Java annotations) are visible to the ZUML document, including EL expressions, data binding and zscript, as depicted below:
+
Then, we could access it by specifying the variable resolver: <javadoc>org.zkoss.zkplus.cdi.DelegatingVariableResolver</javadoc> as shown below:
  
 
<source lang="xml" high="1">
 
<source lang="xml" high="1">
Line 28: Line 28:
 
</window>
 
</window>
 
</source>
 
</source>
 +
 +
<javadoc>org.zkoss.zkplus.cdi.DelegatingVariableResolver</javadoc> resolves all variables defined by CDI (with Java annotations). In other words, it makes them visible to the ZUML document, including EL expressions, data binding and zscript.
 +
 +
For more information, please refer to the following blogs:
 +
 +
* [http://blog.zkoss.org/index.php/2010/01/07/integrate-zk-and-jsr-299weld/ Integrate ZK and JSR-299]
 +
* [http://blog.zkoss.org/index.php/2010/02/11/handling-zk-events-using-cdi-event-notification-model/ Handling ZK Events using CDI event notification model]
  
 
=Version History=
 
=Version History=

Revision as of 02:43, 29 November 2010

CDI (JSR-299) is an emerging standard for contexts and dependency injection for Java EE.

Here we discuss how to use CDI with ZK, especially the use of DelegatingVariableResolver. It provides the basic support of CDI: allow a ZUML document to access variables defined in CDI. For more comprehensive support, please refer to another product: ZK CDI.

Example

Here is a Hello World example. Suppose we have a Java class called HelloWorld as shown below.

@Named
@SessionScoped
public class HelloWorld implements Serializable {
    private final String text = "Hello World";
    public String getText() {
        return text;
    }
}

Then, we could access it by specifying the variable resolver: DelegatingVariableResolver as shown below:

<?variable-resolver class="org.zkoss.zkplus.cdi.DelegatingVariableResolver"?>
<window title="ZK + CDI: Hello World" width="300px">
    My weld-injected bean says: ${helloWorld.text}
</window>

DelegatingVariableResolver resolves all variables defined by CDI (with Java annotations). In other words, it makes them visible to the ZUML document, including EL expressions, data binding and zscript.

For more information, please refer to the following blogs:

Version History

Last Update : 2010/11/29


Version Date Content
     



Last Update : 2010/11/29

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