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

MarksheetListAction.java

package in.co.sunrays.proj1.action;
 
import in.co.sunrays.proj1.dto.MarksheetDTO;
import in.co.sunrays.proj1.exception.ApplicationException;
import in.co.sunrays.proj1.service.MarksheetServiceInt;
 
import org.apache.log4j.Logger;
 
/**
 * Marksheet List functionality Action. Performs operation for list, search and
 * delete operations of Marksheet
 * 
 * @author SUNRAYS Technologies
 * @version 1.0
 * @Copyright (c) SUNRAYS Technologies
 */
public class MarksheetListAction extends BaseListAction {
 
    private static Logger log = Logger.getLogger(MarksheetListAction.class);
    private String name;
    private String rollNo;
    private MarksheetServiceInt service;
 
    public void setService(MarksheetServiceInt service) {
        this.service = service;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getRollNo() {
        return rollNo;
    }
 
    public void setRollNo(String rollNo) {
        this.rollNo = rollNo;
    }
 
    /**
     * Performs display operations for MarksheetListAction
     * 
     * @return type String
     * @return INPUT
     */
    public String input() {
        log.debug("MarksheetListAction.input() Start");
        try {
            dtoList = service.list(pageNo, pageSize);
        } catch (ApplicationException e) {
            log.error("Critical Issue ", e);
            return OP_ERROR;
        }
        log.debug("MarksheetListAction.input() End");
        return INPUT;
    }
 
    /**
     * Performs submit operations for MarksheetListAction
     * 
     * @return type String
     * @return SUCCESS
     */
    @Override
    public String execute() {
        log.debug("MarksheetListAction.execute() Start");
        /**
         * Set search parameters
         */
        MarksheetDTO searchDTO = new MarksheetDTO();
        searchDTO.setName(name);
        searchDTO.setRollNo(rollNo);
        try {
            if (OP_DELETE.equalsIgnoreCase(operation) && ids != null) {
                MarksheetDTO deleteDTO = new MarksheetDTO();
                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("MarksheetListAction.execute() End " + operation);
        return INPUT;
    }
 
}
Comments