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

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

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

    all gone

    all gone

    Eclipse下JSF入門

    1.開發(fā)環(huán)境
       與Eclipse下Struts的開發(fā)類似,安裝好Eclipse和Tomcat之后,還需要兩個插件:tomcat 插件和JSF插件(如果相關插件還沒有安裝),以下是相關下載地址:
        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 2005-12-10 12:05 all gone 閱讀(17652) 評論(11)  編輯  收藏 所屬分類: Java

    評論

    # re: Eclipse下JSF入門 2007-01-11 10:10 小鳥[匿名]

    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" %>


    MessageResources.prxxxxx 放在哪進里???


    俺試了,,漏洞百出,,,

    不好意思,俺今天才接觸jsf.....  回復  更多評論   

    # re: Eclipse下JSF入門 2007-01-12 18:28 all gone[匿名]

    # --login.jsp-- 是在資源文件里的
    表示這是在login.jsp中用到的

    肯定只會有一個login.jsp  回復  更多評論   

    # re: Eclipse下JSF入門 2007-08-10 08:31 few

    https://sourceforge.jp/projects/amateras/files
    -----------
    樓主給個日文的鏈接,是在賣弄嗎?  回復  更多評論   

    # re: Eclipse下JSF入門 2007-08-31 00:43 hello

    樓上的不懂不要亂說。

    只有日文的。  回復  更多評論   

    # re: Eclipse下JSF入門[未登錄] 2007-09-14 15:39 kevin

    呵呵,笑死了。日文連接。你不還給個中文的,我也沒看懂啊。下來試試的。  回復  更多評論   

    # re: Eclipse下JSF入門[未登錄] 2007-09-14 15:42 kevin

    myeclipse里面都有,有區(qū)別嗎?  回復  更多評論   

    # re: Eclipse下JSF入門 2008-04-10 14:32 鵝鵝鵝

    小破程序員還挺愛國,還抗日
    這哥們應該早生70年  回復  更多評論   

    # re: Eclipse下JSF入門 2008-10-29 18:56 sfd

    就沒有自動寫發(fā)faces-config.xml文件嘛  回復  更多評論   

    # re: Eclipse下JSF入門 2009-01-13 11:05 飛雪、

    日文的里面點美國國旗應該就都是英文了吧,除了廣告圖片!  回復  更多評論   

    # re: Eclipse下JSF入門[未登錄] 2009-03-17 20:50 躺著讀書

    我也愛日本 咋了

    但是我還是給一個elipse for j2ee的官方版本的jsf環(huán)境設置教程。
    http://www.eclipse.org/webtools/jsf/docs/tutorial/JSFTools_1_0_tutorial.html

    eclipse官方是內(nèi)置了對于jsf的支持的,只是默認這個功能沒有打開。需要配置。新建項目后轉(zhuǎn)到內(nèi)置web程序的視圖。比netbeans 好多了。  回復  更多評論   

    # re: Eclipse下JSF入門 2009-07-27 20:51 fuck japan

    fuck japan  回復  更多評論   

    主站蜘蛛池模板: 噼里啪啦免费观看高清动漫4| 中文成人久久久久影院免费观看| 99久久人妻精品免费二区| 亚洲二区在线视频| 四虎影视成人永久免费观看视频| 亚洲日韩精品一区二区三区无码 | 亚洲综合av永久无码精品一区二区| WWW国产亚洲精品久久麻豆| 国产vA免费精品高清在线观看| 亚洲成人一区二区| 国产精品高清免费网站 | 在线观看亚洲人成网站| 日本免费一区二区三区 | 久久精品九九亚洲精品| 18禁美女黄网站色大片免费观看| 亚洲一区二区三区高清视频| 在线播放免费播放av片| 国产精品观看在线亚洲人成网| 免费A级毛片在线播放不收费| 一级特级女人18毛片免费视频| 久久精品国产亚洲沈樵| 亚洲免费视频观看| 亚洲最大av资源站无码av网址| 国产伦精品一区二区三区免费下载| 老司机福利在线免费观看| 日批日出水久久亚洲精品tv| 国产在线精品一区免费香蕉| 亚洲香蕉免费有线视频| 日本人的色道www免费一区| 国产精品免费久久久久电影网| 亚洲日本在线观看| 在线观看人成视频免费| 高潮毛片无遮挡高清免费视频| 久久香蕉国产线看观看亚洲片| 黄色永久免费网站| 久久精品国产亚洲AV网站 | 91成人在线免费视频| 亚洲精品国产suv一区88| 亚洲午夜久久久影院| 国产精品免费观看久久| 亚洲阿v天堂在线2017免费|