您的位置:首页 > 移动开发

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;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐