Source Code‎ > ‎src‎ > ‎in.co.sunrays.proj1‎ > ‎action‎ > ‎

StudentListAction.java

package in.co.sunrays.proj1.action;
 
import in.co.sunrays.proj1.dto.StudentDTO;
import in.co.sunrays.proj1.exception.ApplicationException;
import in.co.sunrays.proj1.service.StudentServiceInt;
 
import org.apache.log4j.Logger;
 
/**
 * Student List functionality Action. Performs operation for list, search and
 * delete operations of Student
 * 
 * @author SUNRAYS Technologies
 * @version 1.0
 * @Copyright (c) SUNRAYS Technologies
 */
public class StudentListAction extends BaseListAction {
 
    private static Logger log = Logger.getLogger(StudentListAction.class);
    private String firstName;
    private String lastName;
    private String email;
    private StudentServiceInt service;
 
    public void setService(StudentServiceInt service) {
        this.service = service;
    }
 
    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 String getEmail() {
        return email;
    }
 
    public void setEmail(String email) {
        this.email = email;
    }
 
    /**
     * Performs display operations for StudentListAction
     * 
     * @return type String
     * @return INPUT
     */
    public String input() {
        log.debug("StudentListAction.input() Start");
        try {
            dtoList = service.list(pageNo, pageSize);
        } catch (ApplicationException e) {
            log.error("Critical Issue ", e);
            return OP_ERROR;
        }
        log.debug("StudentListAction.input() Start");
        return INPUT;
    }
 
    /**
     * Performs submit operations for StudentListAction
     * 
     * @return type String
     * @return SUCCESS
     */
    @Override
    public String execute() {
        log.debug("StudentListAction.execute() Start");
        /**
         * Set search parameters
         */
        StudentDTO searchDTO = new StudentDTO();
        searchDTO.setFirstName(firstName);
        searchDTO.setLastName(lastName);
        searchDTO.setEmail(email);
        try {
            if (OP_DELETE.equalsIgnoreCase(operation) && ids != null) {
                StudentDTO deleteDTO = new StudentDTO();
                for (int i = 0; i < ids.length; i++) {
                    deleteDTO.setId(ids[i]);
                    service.delete(deleteDTO);
                    pageNo = 1;
                }
            } else if (OP_NEXT.equalsIgnoreCase(operation)) {
                pageNo++;
            } else if (OP_PREVIOUS.equalsIgnoreCase(operation) && pageNo > 1) {
                pageNo--;
            }
            dtoList = service.search(searchDTO, pageNo, pageSize);
            if (dtoList.size() == 0) {
                pageNo--;
                addActionError("No Record Found");
            }
        } catch (ApplicationException e) {
            log.error("Critical Issue ", e);
            return OP_ERROR;
        }
        log.debug("StudentListAction.execute() End " + operation);
        return INPUT;
    }
 
}
Comments