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

📄 profileform.java

📁 struts的一些用的书籍
💻 JAVA
字号:
package app03b.form;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.util.LabelValueBean;

public class ProfileForm extends ActionForm {
  private String displayName;
  private boolean subscribe;
  private String[] interests;
  private int[] cities; // from which you will access our service.
  private int userType; // organization, individual
  private int incomeLevel; // radio buttons
  
  public ArrayList getCityOptions() {
    ArrayList options = new ArrayList();
    options.add(new LabelValueBean("New York", "1"));
    options.add(new LabelValueBean("Chicago", "2"));
    options.add(new LabelValueBean("San Francisco", "3"));
    options.add(new LabelValueBean("Toronto", "4"));
    options.add(new LabelValueBean("Vancouver", "5"));
    return options;
  }

  public ArrayList getIncomeLevelOptions() {
    ArrayList options = new ArrayList();
    options.add(new LabelValueBean("0 - $10,000", "1"));
    options.add(new LabelValueBean("$10,001 - $30,000", "2"));
    options.add(new LabelValueBean("$30,001 - $50,000", "3"));
    options.add(new LabelValueBean("Over $50,000", "4"));
    return options;
  }
  public String getDisplayName() {
    return displayName;
  }
  public void setDisplayName(String displayName) {
    this.displayName = displayName;
  }
  public String[] getInterests() {
    return interests;
  }
  public void setInterests(String[] interests) {
    this.interests = interests;
  }
  public boolean isSubscribe() {
    return subscribe;
  }
  public void setSubscribe(boolean subscribe) {
    this.subscribe = subscribe;
  }
  public int[] getCities() {
    return cities;
  }
  public void setCities(int[] cities) {
    this.cities = cities;
  }
  public int getIncomeLevel() {
    return incomeLevel;
  } 
  public void setIncomeLevel(int incomeLevel) {
    this.incomeLevel = incomeLevel;
  }
  public int getUserType() {
    return userType;
  }
  public void setUserType(int userType) {
    this.userType = userType;
  }
  
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors actionErrors = new ActionErrors();
   	if (displayName.equals("")) {
     	actionErrors.add("no.displayName", new ActionMessage("no.displayName"));
   	} 
   	if (interests==null) {
    	actionErrors.add("no.interest", new ActionMessage("no.interest"));
   	}
  	return actionErrors;
 	}

 
}

⌨️ 快捷键说明

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