在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ HTML/ JSF <h:setPropertyActionListener>標簽
JSF數(shù)據表(h:dataTable)添加刪除
JSF <h:commandLink>標簽
JSF應用程序入門示例
JSF數(shù)據表(ui:repeat)創(chuàng)建表
JSF列表框
JSF數(shù)據表(h:dataTable)DataModel排序數(shù)據
JSF復合組件
JSF <h:inputText>標簽
JSF表單組合框
JSF <h:messages>標簽
JSF <h:message>標簽
JSF轉換日期時間
JSF JDBC連接
JSF <h:inputHidden>標簽
JSF多選列表框
JSF <h:inputSecret>標簽
JSF自定義轉換器
JSF <f:ajax>標簽
JSF生命周期
JSF可重定位資源
JSFJSF用戶界面組件模型
JSF <h:attribute>標簽
JSF驗證器標簽
JSF驗證字符串長度
JSF轉換器標簽
JSF托管bean(Managed Bean)
JSF值變化的事件
JSF UI組件示例
JSF MySQL CURD實例
JSF數(shù)據表(h:dataTable)排序數(shù)據
JSF <h:graphicImage>標簽
JSF <f:convertNumber>標簽
JSF教程
JSF托管Bean
JSF輸出腳本
JSF <h:outputText>標簽
JSF操作事件
JSF驗證正則表達式
JSF數(shù)據表(h:dataTable)行號
JSF <h:setPropertyActionListener>標簽
JSF注入托管bean實例
JSF <h:commandButton>標簽
JSF Web資源
JSF <h:inputFile>標簽
JSF驗證浮點數(shù)值范圍
JSF Facelets視圖
JSF是什么?
JSF Facelets模板
JSF的特性(特點)
JSF自定義驗證器類
JSF單選按鈕
JSF輸出樣式
JSF數(shù)據表(h:dataTable)更新數(shù)據
JSF HTML5友好標記
JSF表單復選框(CheckBox)示例
JSF <h:form>標簽
JSF Facelets技術介紹
JSF輸出格式化
JSF <h:inputtextarea>標簽
JSF驗證整數(shù)范圍
JSF <h:panelGrid>標簽

JSF <h:setPropertyActionListener>標簽

<h:setPropertyActionListener>標簽向一個將bean屬性設置為給定值的組件添加了一個actionlistener。
以下代碼顯示如何使用<f:setPropertyActionListener>標簽。

<h:commandButton id="submit" action="result" value="Show Message"> 
   <f:setPropertyActionListener target="#{userData.data}" 
      value="JSF 2.0 User" />
</h:commandButton>

實例

以下是文件:UserBean.java 中的代碼。

package com.yiibai.common;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name="user")
@SessionScoped
public class UserBean{

  public String username;

  public String outcome(){
    return "result";
  }

  public String getUsername() {
    return username;
  }

  public void setUsername(String username) {
    this.username = username;
  }

}

以下是文件:index.xhtml 中的代碼 -

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      >
    <h:body>
        <h:form id="form">
            <h:commandButton action="#{user.outcome}" value="Click Me">
                <f:setPropertyActionListener target="#{user.username}" value="yiibai" />
            </h:commandButton>
        </h:form>
    </h:body>
</html>

以下是文件:result.xhtml 中的代碼 -

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:h="http://java.sun.com/jsf/html"
      >

    <h:body>

        <h1>JSF 2 setPropertyActionListener example</h1>

        #{user.username}

    </h:body>

</html>

運行測試

打開 NetBeans 創(chuàng)建一個名稱為: setPropertyActionListener 的Web工程,并使用上面文件代碼。運行項目,打開瀏覽器訪問以下網址:

http://localhost:8084/setPropertyActionListener

如果沒有錯誤,應該會看到以下結果 -

點擊“Click Me”按鈕,結果如下 -