Your First JavaServer Faces.

沒事。。。太久沒有寫英文了。。。最近在看JSF。。。找個主題來練練英文。。。。

In this article, I’d like to introduce an easy application written by using JSF pages. This application would show a simple form with one text field and submit button. Users enter their name in the text field and submit the form and then they would see a welcome page with their name on it.

First, you should download the “JavaServer Faces Reference Implementation” from http://java.sun.com/j2ee/javaserverfaces/download.html. It’s a zipped file. After you download it and decompress it, look into the directory “lib”. Copy all the jar files into your web application’s “WEB-INF/lib” directory. You also need jstl.jar and standard.jar files. You could easily get them from the war file in the “samples” directory. Unzip one war file and look for jstl.jar and standard.jar in the “WEB-INF/lib” directory. Copy them into your web application’s “WEB-INF/lib” directory too. In Summary, You need the jar files.

jsf-impl.jarjsf-api.jarcommons-digester.jarcommons-collections.jarcommons-beanutils.jarjstl.jarstandard.jar


Now you need to define your web application in the “WEB-INF/web.xml” file. All JSF pages requested should be processed by a special servlet “FacesServlet”. You should define it in the “web.xml”.

<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"     version="2.4">      <description>         JSF Demo    </description>     <display-name>JSF Demo</display-name>     <servlet>        <servlet-name>Faces Servlet</servlet-name>        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>        <load-on-startup>1</load-on-startup>    </servlet>        <servlet-mapping>        <servlet-name>Faces Servlet</servlet-name>        <url-pattern>*.faces</url-pattern>    </servlet-mapping>        <welcome-file-list>        <welcome-file>index.html</welcome-file>    </welcome-file-list> </web-app>


In the “web.xml”, we define all requested URL with suffix “.faces” should be processed by FacesServlet. In this first JSF example, I’d like to use JSP for the view technology. The FacesServlet would strip off the suffix “.faces” and load the pages with suffix “.jsp”. For example, if you request “/index.faces”, the “/index.jsp” would be processed in the end.

Now lets’ come out with the first JSF page, named with “pages/index.jsp”.

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %><%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %><html><head><title>JSF Demo</title></head><body>    <f:view>        <h:form>            <h3>Please enter your name.</h3>             name: <h:inputText value="#{user.name}"/><p>            <h:commandButton value="Login" action="login"/>        </h:form>    </f:view></body></html>


If this page, I use two JSF’s standard tag libraries, “core” and html“. The <f:view> tag creates the top-level view. Currently, just know its function is a little like the HTML’s <html> tag. All JSF’s tags are begun with it.
<h:form> creates a HTML form and <h:inputText> provide a text field. Take a look at the “#{user.name}”. It tells the JSF implementation to link the text field with the name property of a user object. We’ll see how to link them soon.

<h:commandButton> provide an submit button. What you should note is the action attribute. It’s used to specify the navigation rule. The navigation rules are defined in the faces-config.xml file. It should be located in “WEB-INF” directory. This application’s faces-config.xml file is shown below.

<?xml version="1.0"?><!DOCTYPE faces-config PUBLIC    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"    "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"><faces-config>    <navigation-rule>        <from-view-id>/pages/index.jsp</from-view-id>        <navigation-case>            <from-outcome>login</from-outcome>            <to-view-id>/pages/welcome.jsp</to-view-id>        </navigation-case>    </navigation-rule>            <managed-bean>        <managed-bean-name>user</managed-bean-name>        <managed-bean-class>onlyfun.caterpillar.UserBean</managed-bean-class>        <managed-bean-scope>session</managed-bean-scope>    </managed-bean></faces-config>


See the <from-view-id>, it’s defined as “/pages/index.jsp”. It tells FacesServlet that while there’s a request from “/pages/index.jsp” with an action attribute “login”, defined in <from-outcome>, it should be navigated to “/pages/welcome.jsp”, defined in <to-view-id>.

You also see the <managed-bean>. It defines the bean used by the JSF pages. The bean is in session scope, defined in <managed-bean-scope>. The UserBean is defined like this.

package onlyfun.caterpillar;public class UserBean {    private String name;        public void setName(String name) {        this.name = name;    }        public String getName() {        return name;    }}


The bean’s name “user” is defined in <managed-bean-name>. You could use #{user.name} to get the bean’s name property in JSF pages. Just as you see in the “pages/index.jsp”.

OK! We still have one page “pages/welcome.jsp” not written. It’s shown below.

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %><%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %><html><head><title>JSF Demo</title></head><body>    <f:view>        <h3>Hello! <h:outputText value="#{user.name}"/>!</h3>        <h3>Welcome your JavaServer Faces!</h3>    </f:view></body></html>


The <h:outputText> is used to output the name property of user bean.

Now startup your Servlet container and point your browser to the application’s URL, such as http://localhost:8080/jsfDemo/pages/index.faces. The “pages/index.jsp” would be loaded first. After you enter your name in the text field of “pages/index.jsp” and click the submit button, your name would be stored in the user bean’s name property. Then the FacesServlet navigate from “pages/index.jsp” to “pages/welcome.jsp” according to navigation rules in the faces-config.xml. The “pages/welcome.jsp” would get the name property from the user bean and show it in the page.

以下是对提供的参考资料的总结,按照要求结构化多个要点分条输出: 4G/5G无线网络优化与网规案例分析: NSA站点下终端掉4G问题:部分用户反馈NSA终端频繁掉4G,主要因终端主动发起SCGfail导致。分析显示,在信号较好的环境下,终端可能因节能、过热保护等原因主动释放连接。解决方案建议终端侧进行分析处理,尝试关闭节电开关等。 RSSI算法识别天馈遮挡:通过计算RSSI平均值及差值识别天馈遮挡,差值大于3dB则认定有遮挡。不同设备分组规则不同,如64T和32T。此方法可有效帮助现场人员识别因环境变化引起的网络问题。 5G 160M组网小区CA不生效:某5G站点开启100M+60M CA功能后,测试发现UE无法正常使用CA功能。问题原因在于CA频点集标识配置错误,修正后测试正常。 5G网络优化与策略: CCE映射方式优化:针对诺基亚站点覆盖农村区域,通过优化CCE资源映射方式(交织、非交织),提升RRC连接建立成功率和无线接通率。非交织方式相比交织方式有显著提升。 5G AAU两扇区组网:与三扇区组网相比,AAU两扇区组网在RSRP、SINR、下载速率和上传速率上表现不同,需根据具体场景选择适合的组网方式。 5G语音解决方案:包括沿用4G语音解决方案、EPS Fallback方案和VoNR方案。不同方案适用于不同的5G组网策略,如NSA和SA,并影响语音连续性和网络覆盖。 4G网络优化与资源利用: 4G室分设备利旧:面对4G网络投资压减与资源需求矛盾,提出利旧多维度调优策略,包括资源整合、统筹调配既有资源,以满足新增需求和提质增效。 宏站RRU设备1托N射灯:针对5G深度覆盖需求,研究使用宏站AAU结合1托N射灯方案,快速便捷地开通5G站点,提升深度覆盖能力。 基站与流程管理: 爱立信LTE基站邻区添加流程:未提供具体内容,但通常涉及邻区规划、参数配置、测试验证等步骤,以确保基站间顺畅切换和覆盖连续性。 网络规划与策略: 新高铁跨海大桥覆盖方案试点:虽未提供详细内容,但可推测涉及高铁跨海大桥区域的4G/5G网络覆盖规划,需考虑信号穿透、移动性管理、网络容量等因素。 总结: 提供的参考资料涵盖了4G/5G无线网络优化、网规案例分析、网络优化策略、资源利用、基站管理等多个方面。 通过具体案例分析,展示了无线网络优化中的常见问题及解决方案,如NSA终端掉4G、RSSI识别天馈遮挡、CA不生效等。 强调了5G网络优化与策略的重要性,包括CCE映射方式优化、5G语音解决方案、AAU扇区组网选择等。 提出了4G网络优化与资源利用的策略,如室分设备利旧、宏站RRU设备1托N射灯等。 基站与流程管理方面,提到了爱立信LTE基站邻区添加流程,但未给出具体细节。 新高铁跨海大桥覆盖方案试点展示了特殊场景下的网络规划需求。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值