Java EE 6 和Rational Application Developer 8(RAD8)系列-JSF 2.0简单例子
2011-01-03 09:02
501 查看
Rational Application Developer 8(RAD8)出来之后,试了一下《 Java EE 6 导学》中的JSF例子,下面的截图和代码。
WebSphere Applications Server 测试环境运行效果图
Rational Application Developer 8(RAD8)图形化设计关键界面
页面代码和managed bean 代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelets Hello Greeting</title>
</h:head>
<h:body>
<h:form>
<h2>Hello, my name is ChinaJava.net. What’s yours?</h2>
<h:inputText id="username"
value="#{hello.name}"
required="true"
requiredMessage="A name is required."
maxlength="25">
</h:inputText>
<p></p>
<h:commandButton id="submit" value="Submit" action="response1">
</h:commandButton>
<h:commandButton id="reset" value="Reset" type="reset">
</h:commandButton>
</h:form>
</h:body>
</html>
-----------------------------------------------------
response1.xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelets Hello Response</title>
</h:head>
<h:body>
<h:form>
<h2>Hello, #{hello.name}!</h2>
<p></p>
<h:commandButton id="back" value="Back" action="index1" />
</h:form>
</h:body>
</html>
-----------------------------------------------
package hello1;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class Hello {
private String name;
public Hello() {
}
public String getName() {
return name;
}
public void setName(String user_name) {
this.name = user_name;
}
}
WebSphere Applications Server 测试环境运行效果图
Rational Application Developer 8(RAD8)图形化设计关键界面
页面代码和managed bean 代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelets Hello Greeting</title>
</h:head>
<h:body>
<h:form>
<h2>Hello, my name is ChinaJava.net. What’s yours?</h2>
<h:inputText id="username"
value="#{hello.name}"
required="true"
requiredMessage="A name is required."
maxlength="25">
</h:inputText>
<p></p>
<h:commandButton id="submit" value="Submit" action="response1">
</h:commandButton>
<h:commandButton id="reset" value="Reset" type="reset">
</h:commandButton>
</h:form>
</h:body>
</html>
-----------------------------------------------------
response1.xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelets Hello Response</title>
</h:head>
<h:body>
<h:form>
<h2>Hello, #{hello.name}!</h2>
<p></p>
<h:commandButton id="back" value="Back" action="index1" />
</h:form>
</h:body>
</html>
-----------------------------------------------
package hello1;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class Hello {
private String name;
public Hello() {
}
public String getName() {
return name;
}
public void setName(String user_name) {
this.name = user_name;
}
}
相关文章推荐
- 在Rational Application Developer中开发简单Portlet
- 在Rational Application Developer中开发简单Portlet(一)
- 在Rational Application Developer中开发简单Portlet(二)
- 使用 Rational Application Developer 6.0 和 WebSphere Portal Server 5.1开发 JSF portlet
- Windows Azure AppFabric 入门教学系列 (二):一个简单的Service Bus例子
- Microsoft .NET Framework 2.0 Application Development Foundation 翻译系列4(第一章:第一课值类型的使用②)
- 在Java EE 6中使用JSF 2.0简化页面制作
- struts2.0简单的例子
- Microsoft .NET Framework 2.0 Application Development Foundation 翻译系列9(第二章 I/O:第一课 文件系统操作)
- Caffe学习系列(9):运行caffe自带的两个简单例子
- 最简单的Ogre系列之一——Ogre框架程序(不使用ExampleListener/Application)
- 使用 Rational Application Developer 构建 HTTPS Web 服务,第 1 部分:Web 服务与 Web 服务客户机
- Caffe学习系列(9):运行caffe自带的两个简单例子
- JSF 2.0 新特性预览系列(Part 1:)ProjectStage
- 如何用 Rational Application Developer 7.0 及更新版在 JSP 中使用 Service Data Objects
- JSF 2.0简单示例
- Caffe学习系列(9):运行caffe自带的两个简单例子
- 增强学习系列之(二):实现一个简单的增强学习的例子
- struts2入门-第一个例子==》第一个struts2实例——HelloWorld==》Struts2.0搭建和简单实例==>写一个Steuts2的经典入门案例,做了一个登陆程序作为入门例子
- Django2.0从搭建环境到部署到服务器简单例子及版本问题