国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

AJAX支持的自動填充表單

2019-11-18 16:36:54
字體:
供稿:網(wǎng)友

jsf的一個Ajax擴展項目, 其實對于使用myfaces的用戶來說還有個更的選擇:使用MyFaces Sandbox 中的 InputSuggestAjax   用法如下:

1.創(chuàng)建一個managed bean:

package test;

import java.util.ArrayList;

import java.util.List;

public class Bean {    

            //In that function all what you had to do is to

            //Specify what will be displayed in the list

            //Note that the keyWord is the text entered by the user

            public List getSuggestedWords(String keyword) {

                        List list = new ArrayList();

                        list.add(keyword + " Ahmed Saleh");

                        list.add(keyword + " Kahki");

                        list.add(keyword + " Kourany");

                        list.add(keyword + " Kiki");

                        list.add(keyword + " Saleh Abouetta");

                        list.add(keyword + " Hashim");

                        return list;

            }

            public String getCurrentValue() {

                        return currentValue;

            }
            public void setCurrentValue(String currentValue) {

                        this.currentValue = currentValue;

            }
            String currentValue;

}

2.     jsp 頁面代碼

<%@ taglib uri="

<%@ taglib uri="

<%@ taglib uri="

<html>

<head>

<title>Ajax JSF sample (InputSuggestAjax)</title>

</head>

<body>

<f:view>

 <h:form>

  <h:outputText value="Enter your name : "/>

   <s:inputSuggestAjax suggestedItemsMethod="#{bean.getSuggestedWords}"

    value="#{bean.currentValue}" />

   <br />

   <h:commandButton action="" value="Submit"/>

   <br />

   <h:outputText value="Your name is #{bean.currentValue}"/>

 </h:form>

</f:view>

</body>    

</html> 

 3.  web.xml配置

<context-param>

  <param-name>javax.faces.STATE_SAVING_METHOD</param-name>

  <param-value>client</param-value>

</context-param>

//Instead of server make the state saving method on the client to make it works


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 当雄县| 广昌县| 云林县| 通道| 太和县| 桃源县| 左云县| 肃北| 平阴县| 天水市| 蒙城县| 监利县| 博野县| 伊金霍洛旗| 巴南区| 沙湾县| 新平| 和平区| 桑日县| 沾益县| 旺苍县| 抚远县| 古交市| 安顺市| 安庆市| 花莲市| 都兰县| 济阳县| 眉山市| 武清区| 太康县| 邢台县| 长丰县| 德清县| 昌宁县| 牟定县| 冷水江市| 临沭县| 郑州市| 吉木乃县| 沐川县|