Package example.ex1

Source Code of example.ex1.HelloWorldAction

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;
    }
}
TOP

Related Classes of example.ex1.HelloWorldAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.