⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formtest.java

📁 2005年出版之《Beginning Java Server Pages》亚马逊书评5颗星
💻 JAVA
字号:
/*
 * Skeleton
 *
 */
package skeleton.action;

import webwork.action.ActionSupport;
import webwork.action.CommandDriven;

import java.util.ArrayList;


/**
 * A sample action
 *
 * @author Matt Baldree (matt@smallleap.com)
 * @version $Revision: 1.3 $
 */
public class FormTest extends ActionSupport implements CommandDriven
{
    String user = "";
    String comments = "";
    int age = 0;
    ArrayList things = new ArrayList();

    public void setUser(String user)
    {
        this.user = user;
    }

    public String getUser()
    {
        return user;
    }

    public void setComments(String comments)
    {
        this.comments = comments;
    }

    public String getComments()
    {
        return comments;
    }

    public ArrayList getThings()
    {
        if (age < 25)
        {
            things.add("Go to College");
            things.add("Buy a car");
            things.add("Travel overseas");
        }
        else if (age < 35)
        {
            things.add("Get a job");
            things.add("Buy a house");
            things.add("Get married");
        }
        else
        {
            things.add("Do whatever you want!");
        }

        return things;
    }

    public int getAge()
    {
        return age;
    }

    public void setAge(int age)
    {
        this.age = age;
    }

    protected void doValidation()
    {
        if (user.equals(""))
        {
            addError("user", "Missing name");
        }

        if (age < 18)
        {
            addError("age", "Age cannot be less than 18");
        }
    }

    protected String doExecute() throws Exception
    {
        // Process data
        return SUCCESS;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -