Package com.vst.webapp.action

Source Code of com.vst.webapp.action.EquipmentInspectionController

package com.vst.webapp.action;

import com.vst.model.EquipmentInspection;
import com.vst.service.EquipmentInspectionManager;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Created by IntelliJ IDEA.
* User: Администратор
* Date: 07.07.2009
* Time: 14:52:59
* To change this template use File | Settings | File Templates.
*/
public class EquipmentInspectionController implements Controller {
    EquipmentInspectionManager equipmentInspectionManager;

    public void setEquipmentInspectionManager(EquipmentInspectionManager equipmentInspectionManager) {
        this.equipmentInspectionManager = equipmentInspectionManager;
    }

    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        ModelAndView modelAndView = new ModelAndView("equipmentInspectionList");

        if (httpServletRequest.getParameter("delete") != null) {
            Integer deleteId = Integer.valueOf(httpServletRequest.getParameter("delete"));
            EquipmentInspection equipmentInspection = equipmentInspectionManager.getById(deleteId);
            equipmentInspectionManager.delete(equipmentInspection);
        }


        Integer page = new Integer(0);
        Integer pageCount;
        if (httpServletRequest.getParameter("page") != null) {
            page = (Integer) Integer.parseInt(httpServletRequest.getParameter("page"));
        }
        modelAndView.addObject("list", equipmentInspectionManager.getList(page));
        pageCount = (Integer) equipmentInspectionManager.getList().size();
        if ((pageCount.intValue() % 15) > 0) {
            pageCount = (Integer) (1 + (pageCount.intValue() / 15));
        } else {
            pageCount = (Integer) (pageCount.intValue() / 15);
        }
        if (pageCount.intValue() == 0) {
            pageCount = new Integer(1);
        }
        modelAndView.addObject("page", page);
        modelAndView.addObject("pageCount", pageCount);

     
        return modelAndView;
    }
}
TOP

Related Classes of com.vst.webapp.action.EquipmentInspectionController

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.