package com.ebpm.webdemo.struts;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* SimpleActionForm.java
* @author Daniel Seiler
* Copyright © 2007 EBPM AG. All rights reserved
*
*/
public class SimpleActionForm extends ActionForm {
public static SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
private String firstname;
private String lastname;
private String address;
private String birthdateString;
private float weight;
private boolean married;
private String color;
private int rating;
public SimpleActionForm() {
super();
}
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.firstname = null;
this.lastname = null;
this.birthdateString = null;
this.weight = 0.0f;
this.married = false;
this.address = null;
this.color = null;
this.rating = 0;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getBirthdateString() {
return birthdateString;
}
public void setBirthdateString(String birthdateString) {
this.birthdateString = birthdateString;
}
public Date getBirthdate() {
Date birthdate = null;
if(birthdateString != null) {
try {
birthdate = sdf.parse(birthdateString);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
return birthdate;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public boolean isMarried() {
return married;
}
public void setMarried(boolean married) {
this.married = married;
}
public float getWeight() {
return weight;
}
public void setWeight(float weight) {
this.weight = weight;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getRating() {
return rating;
}
public void setRating(int rating) {
this.rating = rating;
}
}
|