Web display layer technical evaluation-1. Glossary 2. Theoretical Model, 3. Data addressing

Source: Internet
Author: User
Tags xsl
Web display layer technical evaluation terms

The presentation layer is also translated into the presentation layer, presentation layer, and presentation layer.

This article only covers the display Layer Technology Using HTML templates, excluding echo, GWT (Google Web Toolkit), and other tools that generate HTML based on code.

This article mainly discusses the display Layer Technology of server side (for Java language), and further discusses the display Layer Technology of Browser Side (Ajax) (a typical Ajax application is also divided into model, view, controller-data, HTML/CSS, JavaScript ). Note that there are only a few discussions about Ajax in this article, because I am not good at this field. It is just an extension comparison by the way.

An interesting phenomenon. The technical structure of the display layer of server side and browser side is the opposite. Server side has many scripted templates and are popular. Browser Side has many HTML Dom manipulation and HTML view Model Technologies.

This article will mention some technical or framework names, but it is only limited to discussing the technology, the presentation of the relevant content of the framework, and does not involve evaluating other features. For example, this article does not discuss the page component event mechanisms such as link URL generation, Action URL generation, and button script generation.

This article is an in-depth discussion. Instead of simply replacing a string with a hello World case, We will exhaust the capabilities of various display layer technologies and explore them in a complex layout (such as dynamic include) complex display logic (conditions, loops, nesting, recursion) and other functions.

 

By the way, (considering the wide masses of technologies such as site mesh and Struts tiles taglib), we may need to make a special mention. This article will not discuss the layout technologies such as site mesh and tiles (named include ).

Site mesh is equivalent to a simplified version of XSL. It only retains the ability to replace an HTML node according to the (name-> file) configuration. The rest are similar to tiles, the addition of one (name-> file) configuration file is much more advanced than the direct include file.

Thanks to its simple use (simple functionality), this type of technology has received the support of the masses, and the call is high. This article is sorry to ignore this type of technology.

 

It should be noted that there is no perfect solution.

Work is always done, not in the template, or in the Java code. In short, you always have to find a place to do this job. There is no free lunch in the world. On the one hand, features are enhanced, which naturally affects on the other.

Just as, code coupling cannot be completely eliminated. We can only move these coupling points. Today I think it is uncomfortable to move the coupling points to another place; tomorrow, another person will see the problem and move it back. And each of them can tell a lot of truth.

Therefore, it should be noted that there is no absolute winning solution. This document only lists the reference evaluation data for various technical indicators to help readers make accurate evaluations based on their own needs. (Yes, accurate quantitative evaluation, rather than advertising or slogans)

Theoretical Model

If a function is used to describe the entire display process, it looks like this.

F (data, template, display logic) => result html

The display logic is the display logic. Display logic operates data and templates to generate the final result.

This display logic may appear anywhere in various forms.

For example, it may exist as a server side script in the template and output data. It may also exist in the background Java and operate the template node according to data.

In the previous case, the expression of the function formula is: Template script (data) => result

In the latter case, the function formula is expressed as: logic (data, template) => result

 

This model can be used as a standard for the display layer technology.

(1) scripted Template

The display layer technology where HTML and server side scripts are mixed together.

Including JSP, velocity, freemarker, taglib, tapestry, and XSL.

Someone must disagree with this division. There are choose, if, for in XSL. That's okay. This is especially true for taglib and tapestry. I seem to have seen that taglib or tapestry fans have jumped up and shouted. taglib or tapestry is clearly a component technology, component technology, component technology ....

I am sorry. In this narrow model defined currently, the display technology of any template containing logic is classified as script. In addition, the technical performance of such components is more prominent when the logic is expressed.

For example, logical labels such as <foreach> <if-not> <let> <set> of tapestry. In particular, this if not is a special conditional statement, which is not applicable in general programming languages. Of course, tapestry is not very beautiful, as is the logic tag of taglib.

 

(2) template manipulation

Java code directly operates the display layer technology that generates results from templates (such as html dom.

Including xmlc, jdynamite, And rife.

You may not be very familiar with this type of technology. Some typical examples will be provided in the subsequent Feature Analysis to illustrate their respective usage.

An interesting phenomenon is that in Browser Side (Ajax), this type of display technology is very common because Java Script is very convenient to operate HTML Dom. On the contrary, the scripted template technology is rare in Browser Side. Some typical examples will be given later when we discuss Browser Side.

 

(3) model match

The Java code provides a data model that meets the requirements of the display layer. The display layer framework matches the data model and template to generate results.

Including wicket, fastm, domplus, and so on.

As with swing, Wicket provides different view models for different UI component, such as tables, lists, and labels. Fastm and domplus support pojo, but they also need to meet some framework-specific conventions.

Some may say that some display tag lib and Tapestry components may also need Java code to provide special view data model.

However, a special view data model is not a good feature, meaning pojo is not supported.

Data addressing

Before the formal start, describe the concept of data addressing.

Data addressing refers to data access and attribute acquisition. There are two main types of styles.

(1) ognl Style

Http://www.ognl.org/

Ognl (object graph Navigation language) is so famous and deeply rooted that I use ognl style here to represent the Java Bean attribute addressing method.

For example, a. B [1]. C. d [2]. Name

The other is, of course

(2) XPath Style

For example, a/B [1]/C/[d]/@ name

XPath style is mainly used in XSL.

A jxpath project can access Java Bean attributes in XPath mode.

Http://jakarta.apache.org/commons/jxpath/

 

With simple addressing, ognl and XPath can correspond. However, both ognl and XPath are powerful languages, and the complex usage does not correspond to each other.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.