JSF Languages

Some earlier web technologies intermingle HTML or XHTML and various other programming languages. Disadvantages include:

JSF is designed to use different languages for different aspects of a web application. These languages include:

Extensible Markup Language (XML)

XML is not really a single language. It is a metalanguage for capturing document structures in textual form. XML defines a syntax for adding markup tags to text, but does not itself define any markup tags. It is left to individual languages to specify the markup tags and their meaning.

In JSF there are a few configuration files that use specialized XML variants. These files are placed into the "Web Pages/WEB_INF" folder in the NetBeans development view.

For developers, the most important XML-based language for JSF is XHTML. For writing XHTML it is useful to understand the motivation and structure of XML tags.

Motivation

A flexible document structuring language must be able to model hierarchical structures, much like the Composite design pattern. Generally such languages need to deal with three problems:

Programming languages such as C, C++, and Java, for example, have a structure for if statements. This form is shown below with color coding to indicate the language elements for dealing with the three needs described above.

if (condition) {
statements
}

XML based languages meet the three needs with a different syntax as shown below.

<tag-name attributes-list>
content
</tag-name>

XML Tags

<tag-name attributes-list>
content
</tag-name>

Here tag-name identifies the type of element such as head, body, ul, or table in XHTML. attributes-list is a space-separated sequence of attributes, each with the form

    attribute-name=attribute-value
      

where attribute-name is the name of an attribute and attribute-value is a single-quoted or double-quoted string specifying the value of the attribute. Most XHTML elements, for example, can have attributes named class and id. The value for class is just a name that can be used in style sheet rules to control the styling. The value for id identifies elements that need to be referenced by other elements.

content is a mixture of ordinary text and elements, allowing the overall structure to be viewed as an example of the Composite design pattern.

Extensible HyperText Markup Language (XHTML)

XHTML is HTML that adheres to the stricter tag rules of XML. It is used for web pages that are designed to avoid browser variations due to the laxity of HTML. XHTML file names have a ".xhtml" suffix. In NetBeans they appear in the "Web Pages" folder of the development view.

Each screen of a JSF application is normally specified by an XHTML file. Using the extensibility of XHTML, JSF has several tag libraries specifying new tags that can be used:

Java

In JSF, Java is the language for all of the business logic. There are three Java technologies that play an important "glue" role in connecting the business logic to other parts of a JSF application. In NetBeans they are usually placed in package subfolders of the "Source Packages" folder of the development view.

Expression Language (EL)

Any complex web application framework need some mechanism for linking web pages with application and business logic. JSF uses EL embedded in the XHTML files for this purpose. EL expressions can be identified by their "${" and "}" delimiters.

For example, the expression "${user.name}" can access the "name" property of the bean named "user". This expression can be used in an XHTML file wherever the user name needs to be displayed.

EL is kept simple to avoid problems with embedded quotation and escape mechanisms.

Structured Query Language (SQL)

SQL is a standard language for accessing relational databases such as Oracle, Apache Derby, MySQL, and PostgreSQL. SQL file names have a ".sql" suffix. The SQL commands are used in two ways in JSF applications:

Cascading Style Sheets (CSS)

CSS is the standard web language for controlling the style of web pages. CSS file names have a ".css" suffix. They can be referenced by several XHTML files to facilitate consistent styling of web pages. In NetBeans they are usually placed in the "Web Pages/resources/css" folder of the development view.

JavaScript

The basic operation of a web application involves a lot of client-server communication. This communication puts a heavy burden on the server, which can be communicating with a large number of clients. The network communication also introduces inevitable delays. These problems can be alleviated by execution some application code in client browsers.

JavaScript is the standard web language for client-side executable code. JavaScript file names have a ".js" suffix. They can be referenced by several XHTML files to facilitate consistent client-side behavior for web pages. In NetBeans they are usually placed in the "Web Pages/resources/javascript" folder of the development view.

Although client-side execution has important performance advantages, it must be used with care. The strength of server-side execution is security. Care must be taken to ensure that client-side execution does not undo this security benefit.