<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    love fish大鵬一曰同風起,扶搖直上九萬里

    常用鏈接

    統(tǒng)計

    積分與排名

    friends

    link

    最新評論

    Eclipse下JSF入門 (轉(zhuǎn))

    1.開發(fā)環(huán)境
    ? ?與Eclipse下Struts的開發(fā)類似,安裝好Eclipse和Tomcat之后,還需要兩個插件:tomcat 插件和JSF插件(如果相關(guān)插件還沒有安裝),以下是相關(guān)下載地址:
    ? ? Eclipse SDK:
    ? ? ? ? http://www.eclipse.org/downloads/index.php?
    ? ? JSF:
    ? ? ?https://sourceforge.jp/projects/amateras/files/ ?
    ? ? ? FaceIDE+htmlEditor,htmlEditer也是必要的
    ? ? Tomcat :
    ? ? ? ? ?http://www.sysdeo.com/eclipse/tomcatplugin?
    ? ? Plugin Search:
    ? ? ? ? ?http://eclipse-plugins.2y.net/eclipse/search.jsp?
    ? ?插件的安裝和配置有問題請直接Google。
    2.開始
    ? ? 入門嘛,我們就找一個最簡單的Login就可以了

    ? ? 新建Tomcat project
    ? ? 加入JSF支持

    ? ? 新建一個ManagedBean:


    /**
    ?*
    ?*/
    package com.jsf;




    /**
    ?* @author lzy
    ?*
    ?*/
    public class UserBean {
    private String name;
    ? ? private String password;
    public String verify() {
    ? ? ?if(this.name.equals("name")&&this.password.equals("password"))
    ? ? ?
    ? ? ? ? return "failure";

    ? ?else
    ? ? ? ? return "success";
    }

    ?
    /**
    * @return Returns the name.
    */
    public String getName() {
    return name;
    }

    /**
    * @param name The name to set.
    */
    public void setName(String name) {
    this.name = name;
    }


    /**
    * @return Returns the password.
    */
    public String getPassword() {
    return password;
    }

    /**
    * @param password The password to set.
    */
    public void setPassword(String password) {
    this.password = password;
    }


    }

    ? ? ?新建兩個JSP頁面,login.jsp,welcom.jsp

    login.jsp
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <html>
    <head>
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <html>
    <head>
    <link href="main.css" rel="stylesheet"/>
    <title></title>

    </head>
    <body>
    ? ? <f:view>
    ? ? <f:loadBundle basename="com.jsf.MessageResources" var="msgs"></f:loadBundle>
    ? ?
    ? ? ? ? <h:form>
    ? ? ? ? <h:panelGrid columns="3" headerClass="header" rowClasses="evenRow,oddRow">
    ? ? ? ? <f:facet name="header" >
    ? ? ? ? <h:outputText value="#{msgs.header}"/>
    ? ? ? ? </f:facet>
    ? ? ? ?
    ? ? ? ? <h:outputText value="#{msgs.namePromt}"></h:outputText>
    ? ? ? ? <h:inputText id="name" ?required="true" value="#{user.name}">
    ? ? ? ? <f:validateLength minimum="2" maximum="10"></f:validateLength>
    ? ? ? ? </h:inputText>
    ? ? ? ? <h:message for="name" errorClass="errors"/>
    ? ? ? ?
    ? ? ? ?
    ? ? ? ? <h:outputText value="#{msgs.passwordPromt}"></h:outputText>
    ? ? ? ?
    ? ? ? ? <h:inputSecret id="password" value="#{user.password}" required="true" redisplay="true">
    ? ? ? ? <f:validateLength minimum="2"></f:validateLength>
    ? ? ? ? </h:inputSecret>
    ? ? ? ? <h:message for="password"/>
    ? ? ? ?
    ? ? ? ?
    ? ? ? ? ? ? ? <f:facet name="footer" >
    ? ? ? ? <h:outputText value="#{msgs.footer}"/>
    ? ? ? ? </f:facet>
    ? ? ? ? </h:panelGrid> ? ? ? ? ?
    ? ? ? ? ? ? <h:commandButton value="#{msgs.submitPromt}" action="#{user.verify}"/>
    ? ? ? ? ? ? <h:commandButton value="#{msgs.resetPromt}" type="reset"/>
    ? ? ? ? </h:form>
    ? ? </f:view>
    </body>
    </html>



    welcome.jsp


    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
    <title></title>
    </head>
    <body>
    ? ? <f:view>
    ? ? ? ? <h:outputText value="#{user.name}"/> ?is a good boy!
    ? ? ? ? <h3>welcome JavaServer Faces</h3>
    ? ? </f:view>
    </body>

    </html>
    ? ? ?編輯WEB-INF/lib下的faces-config.xml

    struts-config.xml

    <?xml version="1.0"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
    <navigation-rule>
    ? ? ? ? <from-view-id>/login.jsp</from-view-id>
    ? ? ? ? <navigation-case>
    ? ? ? ? ? ? <from-outcome>success</from-outcome>
    ? ? ? ? ? ? <to-view-id>/welcome.jsp</to-view-id>
    ? ? ? ? </navigation-case>
    ? ? ? ? <navigation-case>
    ? ? ? ? ? ? <from-outcome>failure</from-outcome>
    ? ? ? ? ? ? <to-view-id>/login.jsp</to-view-id>
    ? ? ? ? </navigation-case>
    </navigation-rule>


    <managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>com.jsf.UserBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    </faces-config>


    ? ? ? ?最后是資源文件

    # --login.jsp--
    header=Welcom
    namePromt=Name:
    passwordPromt=Password:
    amountPromt=Amount:
    datePromt=Date:
    submitPromt=Submit
    resetPromt=Reset
    footer=Thank you!


    3.測試
    在test工程中選擇tomcat project->Update context definition
    然后運行Tomcat
    http://127.0.0.1:8080/jsfTest/login.jsf

    posted on 2006-07-21 01:37 liaojiyong 閱讀(2863) 評論(0)  編輯  收藏 所屬分類: JSF


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導航:
    博客園   IT新聞   Chat2DB   C++博客   博問  
     
    主站蜘蛛池模板: 免费无码又爽又刺激网站| 女人18毛片水真多免费播放| 久久亚洲AV成人出白浆无码国产| 亚洲avav天堂av在线网爱情| 最好免费观看韩国+日本| 成人网站免费大全日韩国产 | 亚洲综合精品一二三区在线| 久久久受www免费人成| 亚洲综合图片小说区热久久| 一区二区三区四区免费视频| 亚洲AV永久无码精品一百度影院 | 少妇无码一区二区三区免费| 亚洲综合成人婷婷五月网址| 在线观看免费人成视频| 一级做性色a爰片久久毛片免费| 亚洲精品视频在线观看你懂的| 日韩精品无码免费视频| 亚洲国产精品综合久久网各| 波多野结衣视频在线免费观看| 国产亚洲精品美女久久久久| 亚洲国产人成中文幕一级二级| 特级毛片免费播放| 久久久久亚洲av成人无码电影| aa级毛片毛片免费观看久| 中文字幕乱码亚洲精品一区| 亚洲av无码专区国产乱码在线观看| 蜜桃视频在线观看免费视频网站WWW| 亚洲欧洲国产经精品香蕉网| 97热久久免费频精品99| 91在线免费观看| 国产偷国产偷亚洲高清在线| 亚洲中文字幕久久精品无码喷水 | 亚洲国产中文字幕在线观看| 国产在线观看片a免费观看| 99在线视频免费观看| 亚洲视频一区在线播放| 亚洲色婷婷一区二区三区| 免费人妻av无码专区| 精品无码国产污污污免费| 无遮免费网站在线入口| 另类图片亚洲校园小说区|