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