随笔 - 571  文章 - 4  评论 - 253  阅读 - 72万

ADF_General JSF系列1_创建一个简单的JSF Application

2015-02-17 Creatd By BaoXinjian

一、摘要


本文介绍如何创建一个简单的Application

Step 1: Create a New Application and Project

Step 2: Create a JSF Page

Step 3: Design the UI

Step 4: Modify the Behavior Through Code

 

1: Create a New Application and Project


Step1. 创建Custom Application

Step2.  查看错所创建的Application

 

2: Create a JSF Page


Step1. 创建测试页面

Step2. 简单测试页面如下

 

3: Design the UI


Step1. 导入HTML和JSF控件

Step2.  最后组成如下控件

 

4: Modify the Behavior Through Code


Step1.  建立Managed Bean

Step2.  添加Button方法

Step3.  查看所创建的Java Managed Bean

Step4. Managed Bean中的代码

复制代码
package project.backing;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlOutputText;

@ManagedBean(name="backing_start")
@RequestScoped
public class StartInfo {
    private HtmlOutputText outputText1;
    private HtmlCommandButton commandButton1;
    private HtmlInputText inputText1;
    private HtmlForm form1;

    public StartInfo() {
    }

    public void setOutputText1(HtmlOutputText outputText1) {
        this.outputText1 = outputText1;
    }

    public HtmlOutputText getOutputText1() {
        return outputText1;
    }

    public void setCommandButton1(HtmlCommandButton commandButton1) {
        this.commandButton1 = commandButton1;
    }

    public HtmlCommandButton getCommandButton1() {
        return commandButton1;
    }

    public void setInputText1(HtmlInputText inputText1) {
        this.inputText1 = inputText1;
    }

    public HtmlInputText getInputText1() {
        return inputText1;
    }

    public void setForm1(HtmlForm form1) {
        this.form1 = form1;
    }

    public HtmlForm getForm1() {
        return form1;
    }

    public Object commandButton1_action() {
        // Add event code here...
        outputText1.setValue("Hello "+inputText1.getValue());
        return null;
    }
}
复制代码

Step5.  页面测试结果,当点击按钮式,将Input的值数据到显示栏位

 

Thanks and Regards

posted on   东方瀚海  阅读(360)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?

点击右上角即可分享
微信分享提示