From Documentation

Jump to: navigation, search

UiFactory is used to instantiate all UI objects, such as session, desktop, and components, and to load ZUML documents. You could customize it to provide the functionality you want.

For example, SerializableUiFactory is the factory used to instantiate sessions that are serializable[1], while SimpleUiFactory, the default factory, instantiates non-serializable sessions.

Here are a list of customization you could do with UI Factory:

Notice that it is suggested to extend from either SerializableUiFactory or SimpleUiFactory, rather than to implement UiFactory from scratch.

  1. Then, the application is able to run in a clustering environment. Fore more information, please refer to the Clustering section

Load ZUML from Database

The default implementation of AbstractUiFactory.getPageDefinition(RequestInfo, String) loads the ZUML document from the Web application's resources (i.e., the files found in a Web application). If you prefer to load from other sources, such as a database, you could override it.

The pseudo code will look like the following:

public class MyUiFactory extends SimpleUiFactory {
    public PageDefinition getPageDefinition(RequestInfo ri, String path) {
        PageDefinition pgdef = getFromCache(path); //your cache implementation
        if (pgdef == null) {
            String content = loadFromDatabase(path); //your resource loading
            pgdef = getPageDefinition(ri, content, "zul"); //delegate to SimpleUiFactory
            setCache(path, pgdef); //cache the result
        return pgdef;

where we assume you implemented loadFromDatabase to load the ZUML document from a database. In addition, you have to implement getFromCache and setCache to cache the result in order to improve the performance of retrieving the document from the database.

On the other hand, the parsing of the ZUML document can be done easily by calling AbstractUiFactory.getPageDefinitionDirectly(RequestInfo, String, String).

Version History

Last Update : 2011/7/27

Version Date Content

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

You got stuck here?
Let us know how we can improve this page
For specific questions please use the forum