JSF entry Note 2

Source: Internet
Author: User

1. Simple navigation
We are modifying faces-config.xml

<Navigation-Rule> -- navigation rule
<From-View-ID>/pages/index. in JSF, the view ID of JSP </from-View-ID> is calculated from the relative path of the Web application environment.
<From-View-ID> is a selective definition that specifies the conditions of the Source Page.
<Navigation-case> define various navigation conditions
<From-outcome> defines the target page to which the form results are directed when the conditions are met. The target page is defined in <to-View-ID>.

2. JSF Expression Language
JSF expression language is used together with JSF labels. It is a simple language used to access data objects.
JSF El starts with # and places the variable or formula between {}. The variable name can be the name defined in the faces-config.xml. If it is Bean, you can use '. 'operator to access its attributes, for example:
<F: View>
<H: outputtext value = "# {user. name}"> </F: View>
The variable name of El can also be the name declared during program execution, or the implicit object predefined by JSF el,
<F: View>
<H: outputtext value = "# {Param. name}"> </F: View>
<F: View>
<H: outputtext value = "# {Param. ['name']}"> </F: View>
Other variable values can be placed [].
<F: View>
<H: outputtext value = "# {somebean. somemap [user. Name]}">
</H: outputtext>
</F: View>
If the variable is a list type or array, you can specify the index in [], for example:
<H: outputtext value = "# {somebean. somelist [0]}">
</H: outputtext>
<H: outputtext value = "# {somebean. somearray [0]}">
</H: outputtext>
Specifies the literal constant. Conversion attempts are made for true, false, String, number, and JSF el.
<H: outputtext value = "# {true}">
</H: outputtext>
<H: outputtext value = "# {Hello world}">
</H: outputtext>

Iii. reserved words or Keywords of JSF
True False null Div mod and or not eq (equals) NE (no equals) lt gt le Ge instanceof

With El, you can perform some arithmetic operations, logical operations, and relational operations directly, just as in common programming languages.
Operators include +,-, ×,/or Div, and remainder % or mod.
Ternary Computation
#{(1 = 2 )? 3: 4} (expression? Result1: result2) If expression is true, result1 is displayed. If expression is false, result2is displayed.

Iv. JSF internationalization Information
The resource file name ends with. properties.
The resource file name consists of basename, language, and region, as shown in figure

Basename. Properties
Basename_en.properties
Basename_zh_cn.properties (to be continued)

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.