Technology Guidelines"

From Documentation
Line 61: Line 61:
  
 
[[ZK Developer's Reference/UI Composing/ZUML|ZUML]] is XML-based approach to declare UI. It does not require programming knowledge, and works well with [[ZK Developer's Reference/MVC|MVC]], [[ZK Developer's Reference/Data Binding|Data Binding]] and others. It is strongly suggested unless you have different preferences (such as pure Java and JSP).
 
[[ZK Developer's Reference/UI Composing/ZUML|ZUML]] is XML-based approach to declare UI. It does not require programming knowledge, and works well with [[ZK Developer's Reference/MVC|MVC]], [[ZK Developer's Reference/Data Binding|Data Binding]] and others. It is strongly suggested unless you have different preferences (such as pure Java and JSP).
 +
 +
Notice that using ZUML does not prevent you from creating components dynamically in Java. In fact, it is a common practice to use ZUML to layout the theme of the Web application, and then use pure Java to manipulate it dynamically.
  
 
==When to use Richlet==
 
==When to use Richlet==

Revision as of 04:40, 16 March 2011


Technology Guidelines


ZK provides end-to-end solutions from UI design, development, testing to production. Here is the technology guidelines to help developers to make choices along the way.

If you are new to ZK and prefer to understand ZK first, you could skip this section and go back later after you understand ZK more.

MVC vs. ZScript

They serve different purposes and could work together. However, some developers got confused about these two technologies.

When to use MVC

MVC (Model-View-Control) is a design pattern that separates the model, view and controller clearly. It is easy to collaborate, develop and maintain. In addition, the performance is great since it is done in compiled Java code. MVC is strongly suggested for development, especially for production systems.

When to use zscript

Zscript allows you to embed Java code in ZUML pages. It speeds up the design cycle, so it could be a good approach for prototyping, POC and testing. It is also good for exploiting ZK features and reporting bugs to ZK. However, Like any interpreter, the performance is not good, and tends to be error prone, so it is not suggested to use in production systems.

MVC Extractor

ZK Studio provides a tool called MVC Extractor that can convert zscript to MVC automatically. It simplifies to transfer the code from prototyping to production.

Documentation links

MVC:
ZSCRIPT:

Data Binding

When to use

Data Binding automates the data-copy plumbing code (CRUD) between UI components and the data source. It is strongly suggested whenever applicable, because it boosts the productivity a lot and the code is easy to read and maintain.

When not to use

Barely. However, it requires more knowledge to learn than EL expressions, so EL expressions is an alternative for people, such as UI designer, not familiar with ZK, especially in the UI design phase.

The other limitation is that it could not be applied a component that is created later (after the page is initialized)[1].


  1. This limitation will be resolved in the upcoming Data Binding 2).

Documentation links

ZUML vs. Richlet vs. JSP

When to use ZUML

ZUML is XML-based approach to declare UI. It does not require programming knowledge, and works well with MVC, Data Binding and others. It is strongly suggested unless you have different preferences (such as pure Java and JSP).

Notice that using ZUML does not prevent you from creating components dynamically in Java. In fact, it is a common practice to use ZUML to layout the theme of the Web application, and then use pure Java to manipulate it dynamically.

When to use Richlet

A richlet is a small Java program that composes a user interface in Java for serving user's request. You could use it if you prefer to compose UI in pure Java (like Swing).

When to use JSP

If you'd like to use ZK in legacy JSP pages, you could use one of following approaches:

  1. Use <jsp:include> to include a ZUL page.
  2. Use ZK JSP Tags in a JSP page directly.

Notice that ZUML support the use of HTML tags well (without JSP). For more information, please refer to ZK Developer's Reference: HTML Tags.

Documentation links

ZUML:
Richlet:
JSP:

Bookmarks vs. Multiple Pages

A traditional page-based Web framework forces developers split an applications into pages. On the other hand, Ajax (ZK) allows developers to group a set of functionality into a single desktop-like page that enables a more friendly user experiences.

Grouping is better to base on the functionality, unless it is a small application. For example, it might not be a good idea to group administration with, say, data entry. Here are some guidelines:

  • If a set of functionality is a logical unit to use and/or to develop, you might group it as a single page.
  • If SEO (i.e., able to be indexed by search engine) is important, it is better to split into multiple pages (and turn on the crawlable option).

Whether UI shares the same template (such as header and footer) does not matter, since it is easy to make multiple pages to appear similarly (by use inclusion, templating and composite).

When to use bookmarks (in single page)

After grouping a set of functionality into a single page, you could still allow users to use BACK and FORWARD to switch among the states of the single page and even bookmark on a particular state, as if there are multiple pages. It can be done by use of so-called Browser History Management (aka., bookmarks). You might consider it is a technique to simulate multiple pages (for a single page with multiple states).

When to use multiple pages

If a set of functionality is logically independent of another, you could make them as separated pages. To jump from one page to another, you could use the so-called send-redirect technique.

Documentation links

Bookmarks:
Multiple Pages:

Native vs. HTML Components

ZK provides several ways to mix HTML tags in a ZUML document.

When to use native

By use of a XML namespace called the native namespace, you could declare any tags in ZUML as long as it is valid to the client (i.e., any HTML tags for a browser). It is suggested to use this technology if the HTML tags are static, i.e., you won't change the content dynamically with Ajax. The header, sidebar, footer and layout elements are typical examples. It saves the memory at the server.

When to use HTML

ZK also provides a set of components to represent each HTML tag at the server. It is suggested if you want to change their content dynamically, since they behave the same as other ZK components. However, since it is a component, it consumes the server's memory.

Documentation links

Performance

For production systems, it is strongly recommended to take a look at Performance Tips first.

JSF

When to use

JSF is a page-based framework and too complicated. We strongly recommend to use ZK instead of JSF. ZK can do whatever JSF can, and better. However, if you have to use ZK with legacy JSF, please refer to the Embed ZK Component in Foreign Framework section[1].


  1. Notice that ZK JSF Components is no longer supported.

Version History

Last Update : 2011/03/16


Version Date Content
     


Last Update : 2011/03/16

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