Jsf-expression-language
提供:Dev Guides
JSF-式言語
JSFは豊富な表現言語を提供します。 *#\ {operation-expression} *表記を使用して通常の操作を記述できます。 JSF式言語の利点の一部を次に示します。
- Beanプロパティを参照できます。Beanは、リクエスト、セッション、またはアプリケーションスコープに格納されているオブジェクト、または管理対象Beanです。
- リスト、マップ、配列などのコレクションの要素に簡単にアクセスできます。
- リクエストなどの定義済みオブジェクトに簡単にアクセスできます。
- 式言語を使用して、算術演算、論理演算、およびリレーショナル演算を実行できます。
- 自動型変換。
- NullPointerExceptionの代わりに空の文字列として欠損値を表示します。
応用例
式言語をテストするテストJSFアプリケーションを作成しましょう。
Step | Description |
---|---|
1 | Create a project with a name helloworld under a package com.finddevguides.test as explained in the JSF - First Application chapter. |
2 | Modify UserData.java under package com.finddevguides.test as explained below. |
3 | Modify home.xhtml as explained below. Keep the rest of the files unchanged. |
4 | Compile and run the application to make sure the business logic is working as per the requirements. |
5 | Finally, build the application in the form of war file and deploy it in Apache Tomcat Webserver. |
6 | Launch your web application using appropriate URL as explained below in the last step. |
UserData.java
home.xhtml
すべての変更を完了したら、JSF-最初のアプリケーションの章で行ったようにアプリケーションをコンパイルして実行します。 すべてがアプリケーションで問題ない場合、次の結果が生成されます。