package example.ex1;
import com.opensymphony.xwork.ActionSupport;
import java.util.Date;
import example.User;
/**
* example.ex1.HelloWorldAction
* @author Jason Carreira
* Date: Mar 29, 2004 9:59:17 PM
*/
public class HelloWorldAction extends ActionSupport {
private User user = new User();
public User getUser() {
return user;
}
public int getDaysTillNextBirthday() {
Date birthday = user.getBirthday();
if (birthday != null) {
return calculateDaysTillNextBirthday(birthday);
}
return 0;
}
public String execute() throws Exception {
User user = getUser();
String name = user.getName();
if ((name == null) || (name.trim().equals(""))) {
addFieldError("user.name", "You must enter a name.");
}
if (hasErrors()) {
return INPUT;
}
return SUCCESS;
}
private int calculateDaysTillNextBirthday(Date birthday) {
return 1;
}
}