Jsf-parameters-tag
提供:Dev Guides
JSF-ui:paramタグ
_ui:param tag_を使用して、テンプレートファイルまたはインクルードファイルにパラメーターを渡すことができます。
JSF-template tagsの章では、テンプレートタグを作成して使用する方法を学びました。 ヘッダー、フッター、コンテンツ、すべてのセクションを組み合わせたテンプレートなど、さまざまなセクションを定義しました。
今、私たちは学びます-
- テンプレートのさまざまなセクションにパラメーターを渡す方法 *パラメータをテンプレートに渡す方法
テンプレートのセクションのパラメーター
パラメーターの作成:common.xhtml
ui:includeタグにパラメーターを追加します。* ui:param *タグを使用して、Headerセクションに渡す値を含むパラメーターを定義します。
パラメーターを使用:header.xhtml
テンプレートへのパラメーター
パラメーターの作成:home.xhtml
ui:compositionタグにパラメーターを追加します。 ui:param タグを使用して、テンプレートに渡す値を含むパラメーターを定義します。
パラメーターを使用:common.xhtml
応用例
テストJSFアプリケーションを作成して、JSFのテンプレートタグをテストしましょう。
Step | Description |
---|---|
1 | Create a project with a name helloworld under a package com.finddevguides.test as explained in the JSF - Templates Tag chapter. |
2 | Modify header.xhtml,and common.xhtml files under src → main → webapp → templates folder. Modify them as explained below. |
3 | Modify home.xhtml as explained below. Keep rest of the files unchanged. |
4 | Compile and run the application to make sure 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. |
header.xhtml
common.xhtml
home.xhtml
すべての変更を完了したら、JSF-最初のアプリケーションの章で行ったようにアプリケーションをコンパイルして実行します。 すべてがアプリケーションで問題ない場合、次の結果が生成されます。