JSF2 の概要

a graph image

サンプルプログラム

screen.png

xhtml から ManagedBean? の呼び出し

<h:commandButton value="投稿" action="#{commentController.doPublish}"/>

で、commentController の doPublish() が呼び出される。
ボタンではなく、リンクで呼び出したいときは

<h:commandLink value="投稿" action="#{commentController.doPublish}"/>

xhtml での入力内容を ManagedBean? に格納する

<h:inputText value="#{commentController.comment}"/>

で、commentController の setComment() が呼び出される

ManagedBean? から xhtml の呼び出し

public class CommentController {
   public String doPublish() {
       return "simpleResult.xhtml";
   }
}

h:commandButton> から呼び出されるメソッドの返値の型は String で、xhtml 名を返す。

ManagedBean? のフィールド変数を xhtml で読み出す

<h:outputText value="#{commentController.comment}"/>

で、commentController の getComment() が呼び出される

xhtml から xhtml の呼び出し

<h:link outcome="simpleComment" value="戻る" />

で、simpleComment.xhtml が呼び出される

xhtml をディレクトリ分けする

WebContent
  |
  +-simpleComment.xhtml
  |
  +-sub
      |
      +-simpleReuslt.xhtml

のように、配置した場合には、どのようにリンクを設定すれば良いか?

ManagedBean? に参照名をつけたい


Glassfish JSF2


添付ファイル: filescreen.png 1778件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2013-06-09 (日) 11:34:16 (3967d)
Short-URL: https://at-sushi.com:443/pukiwiki/index.php?cmd=s&k=4565d496f0
ISBN10
ISBN13
9784061426061