读《JavaServer Faces 核心编程(第3版)》一书的记录—— 第1章 JSF 简介——案例 login

本文详细介绍了如何使用JavaServer Faces技术进行项目阅读与理解的过程,包括安装环境、使用随书例题创建项目、运行项目、浏览项目结构、分层阅读等步骤,并通过实例展示了如何在前端页面中使用管理bean进行数据交互。
All +All -

login  

  • + -读书准备工作描述
    • 安装JDK7或者以上版本
    • + -安装NetBeans 7或者以上版本
      • 采用完全安装
    • + -采用随书提供的例题源代码,创建项目
      • 这里采用的源代码是javaee文件夹下的
      • 这里采用的应用服务器是GlassFish Server 3
  • + -读书方式描述(完全以“剥白菜法”来读项目)
    • + -第一阶段:运行项目
      • + -运行项目
        • 打开项目首页
        • 填写Name和Password
        • 点击“Login”按钮-->打开welcome.xhtml页面
    • + -第二阶段:浏览项目
      • + -浏览项目结构
        • 在“项目”窗口中浏览项目的逻辑文件结构
        • 在“文件”窗口中浏览项目的物理文件结构
        • 在“服务”窗口中浏览项目关联的“数据库”和“服务器”
    • + -第三阶段:项目分层阅读
      • + -第一层面:视图层
        • 从项目的首页“index.xhtml”开始
        • 到欢迎页面“welcome.xhtml”结束
      • 第二层面:页面后台管理层
        • + -管理bean的实例对象名称: user
          • user是UserBean的一个实例对象
          • 用标注@Named("user")将该对象注入到JSF上下文中
            • 形式如下所示:

              import javax.enterprise.context.SessionScoped;

              import javax.inject.Named;

              @Named("user")

              @SessionScoped

              public class UserBean implements Serializable {

          • 用标注将该对象的作用域限定为session范围
            • 形式如下所示:

              import javax.enterprise.context.SessionScoped;

              import javax.inject.Named;

              @Named("user")

              @SessionScoped

              public class UserBean implements Serializable {

          • 要实现接口Serializable使其对象可序列化
            • 形式如下所示:

              import java.io.Serializable;

              import javax.enterprise.context.SessionScoped;

              import javax.inject.Named;

              @Named("user")

              @SessionScoped

              public class UserBean implements Serializable {

          • 复合JavaBean的标准
        • 在index.xhtml页面中,使用管理bean
        • 在welcome.xhtm页面中使用管理bean
      • + -第三层面:后台数据持久管理层
      • + -第四层面:后台数据持久对象层
      • + -第五层面:后台数据持久物理层
  • + -读书分层记录描述
    • + -第一层面:视图层
      • + -从项目的首页“index.xhtml”开始
        • +-页面需要的标签库,在这里是使用标签html的特性xmlns(命名空间)的值来定义的
          • xmlns="http://www.w3.org/1999/xhtml"
          • +-xmlns:h="http://java.sun.com/jsf/html"
            • xmlns:h中的h是在引用该标签库的标签时的“前缀”符合
            • 允许使用其它字母来表示
        • +-头部
          • +-JSF HTML标签
            • h:head
          • +-HTML标签
            • title
        • +-主体部分
          • +-JSF HTML标签
            • h:body
            • h:form
            • +-h:inputText
              • +-特性
                • value="#{user.name}"
              • +-组件类型
                • 输入文本
            • +-h:inputSecret
              • +-特性
                • value="#{user.password}"
              • +-组件类型
                • 输入文本
            • +-h:commanButton
              • +-特性
                • value="Login"
                • action="welcome"
              • +-组件类型
                • 命令按钮
      • + -到欢迎页面“welcome.xhtml”结束
        • +-主体部分
          • +-HTML标签
            • +-h3
              • 文本:Welcome to JavaServer Faces, #{user.name}!
    • + -第二层面:页面后台管理层
      • + -管理bean的实例对象名称: user
        • user是UserBean的一个实例对象
        • +-用标注@Named("user")将该对象注入到JSF上下文中
          • 形式如下所示:

            import javax.enterprise.context.SessionScoped;

            import javax.inject.Named;

            @Named("user")

            @SessionScoped

            public class UserBean implements Serializable {

        • +-用标注将该对象的作用域限定为session范围
          • 形式如下所示:

            import javax.enterprise.context.SessionScoped;

            import javax.inject.Named;

            @Named("user")

            @SessionScoped

            public class UserBean implements Serializable {

        • +-要实现接口Serializable使其对象可序列化
          • 形式如下所示:

            import java.io.Serializable;

            import javax.enterprise.context.SessionScoped;

            import javax.inject.Named;

            @Named("user")

            @SessionScoped

            public class UserBean implements Serializable {

        • 复合JavaBean的标准
      • + -在index.xhtml页面中,使用管理bean
        • +-value="#{user.name}"
          • 管理bean user访问其属性name的值
          • +-该表达式应用在“输入文本”组件上时,访问的是属性的设置方法
            • 名称:setName()
            • 参数:输入的文本
        • +-value="#{user.password}"
          • 管理bean user访问其属性password的值
          • +-该表达式应用在“输入文本”组件上时,访问的是属性的设置方法
            • 名称:setPassword()
            • 参数:输入的文本
        • +-value="Login"
          • “Login”是该按钮上显示的文本
          • 这里没有使用表达式语言,而是直接值:字符串
        • +-action="welcome"
          • +-“welcome”就是JSF页面导航字符串
            • 在JSF2.0中,该字符串默认导航到同名页面去
          • 这里没有使用表达式语言,而是直接值:字符串
          • 当点击该按钮时,程序导航到字符串“welcome”同名的页面“welcome.xhtml”去
      • + -在welcome.xhtm页面中,使用管理bean
        • +-#{user.name}
          • 管理bean user访问其属性name的值
          • +-该表达式应用在“输出文本”组件上时,访问的是属性的读取方法
            • 名称:getName()
Product Description JavaServer Faces (JSF) is the standard Java EE technology for building web user interfaces. It provides a powerful framework for developing server-side applications, allowing you to cleanly separate visual presentation and application logic. JSF 2.0 is a major upgrade, which not only adds many useful features but also greatly simplifies the programming model by using annotations and “convention over configuration” for common tasks. To help you quickly tap into the power of JSF 2.0, the third edition of Core JavaServerFaces has been completely updated to make optimum use of all the new features. The book includes Three totally new chapters on using Facelets tags for templating, building composite components, and developing Ajax applications Guidance on building robust applications with minimal hand coding and maximum productivity–without requiring any knowledge of servlets or other low-level “plumbing” A complete explanation of the basic building blocks–from using standard JSF tags, to working with data tables, and converting and validating input Coverage of advanced tasks, such as event handling, extending the JSF framework, and connecting to external services Solutions to a variety of common challenges, including notes on debugging and troubleshooting, in addition to implementation details and working code for features that are missing from JSF Proven solutions, hints, tips, and “how-tos” show you how to use JSF effectively in your development projects Core JavaServerFaces, Third Edition, provides everything you need to master the powerful and time-saving features of JSF 2.0 and is the perfect guide for programmers developing Java EE 6 web apps on Glassfish or another Java EE 6-compliant application servers, as well as servlet runners such as Tomcat 6. From the Back Cover JavaServer Faces (JSF) is the standard Java EE technology for building web user interfaces. It provides a powerful framework for developing server-side applications, allowing you to cleanly separate visual presentation and application logic. JSF 2.0 is a major upgrade, which not only adds many useful features but also greatly simplifies the programming model by using annotations and “convention over configuration” for common tasks. To help you quickly tap into the power of JSF 2.0, the third edition of Core JavaServerFaces has been completely updated to make optimum use of all the new features. The book includes Three totally new chapters on using Facelets tags for templating, building composite components, and developing Ajax applications Guidance on building robust applications with minimal hand coding and maximum productivity–without requiring any knowledge of servlets or other low-level “plumbing” A complete explanation of the basic building blocks–from using standard JSF tags, to working with data tables, and converting and validating input Coverage of advanced tasks, such as event handling, extending the JSF framework, and connecting to external services Solutions to a variety of common challenges, including notes on debugging and troubleshooting, in addition to implementation details and working code for features that are missing from JSF Proven solutions, hints, tips, and “how-tos” show you how to use JSF effectively in your development projects Core JavaServerFaces, Third Edition, provides everything you need to master the powerful and time-saving features of JSF 2.0 and is the perfect guide for programmers developing Java EE 6 web apps on Glassfish or another Java EE 6-compliant application servers, as well as servlet runners such as Tomcat 6.
JSF种用于构建Java Web 应用程序的标准框架(Java Community Process 规定的JSR-127标准)JSF(Java Server Faces)技术为开发基于网络用户界面的Java开发者提供了标准的编程接口API以及标签库。就像Struts框架样,JSF定义了JSF标签 JSF的全称   1、Joint Strike Fighter (JSF)   2、Java Server Faces (JSF) Java Server Faces (JSF)   JSF种用于构建Java Web 应用程序的标准框架(Java Community Process 规定的JSR-127标准)。它提供了种以组件为中心的用户界面(UI)构建方法,从而简化了Java服务器端应用程序的开发。由于由Java Community Process (JCP) 推动,属于Java EE 5中的技术规范,而受到了厂商的广泛支持。   JSF(Java Server Faces)技术为开发基于网络用户界面的Java开发者提供了标准的编程接口API以及标签库。就像Struts框架样,JSF定义了JSF标签,能够生成与JavaBean属性绑定在起的HTML表单元素。从应用开发者的角度看,两种框架十分相似,但是JSF可能会得到更多的支持,因为JSFJava的标准。在未来的发展中,有可能所有的J2EE应用服务器都需要支持JSFJava Server Faces技术好处   引入了基于组件和事件驱动的开发模式,使开发人员可以使用类似于处理传统界面的方式来开发Web应用程序。提供了行为与表达的清晰分离。 不用特别的脚本语言或者标记语言来连接UI组件和Web层。JSF技术API被直接分层在Servlet API的顶端。 技术为管理组件状态提供个丰富的体系机构、处理组件数据、确认用户输入和操作事件。 Java Server Faces应用程序   典型的JSF应用程序包含下列部分:   组JSP页面   组后台bean(为在个页面上的UI组件定义的属性和函数的JavaBean组件)   应用程序配置资源文件(定义页面导航规则、配置bean和其它的自定义对象,如自定义组件)   部署描述文件( web.xml )   组由应用程序开发者创建的自定义对象(有可能)   些可能包含自定义组件、约束、转换器或者监听器的对象   为在页面中表现自定义对象的组自定义tag   包含JSP页面的JSF应用程序也使用由为了表现UI组件和在页面上的其他对象的JSF技术而定义的标准的tag库。 Java Server Faces技术的重要开发框架 sun-ri、myfaces、icefaces、richfaces、seam
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值