com.carlos.projects.billing.ui.controllers.DocumentsController.java Source code

Java tutorial

Introduction

Here is the source code for com.carlos.projects.billing.ui.controllers.DocumentsController.java

Source

/**
 * Fonti is a web application for billing and budgeting
 * Copyright (C) 2009  Carlos Fernandez
 *
 * This file is part of Fonti.
 *
 * Fonti is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Fonti is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.carlos.projects.billing.ui.controllers;

import java.util.HashMap;
import java.util.Map;

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

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;

import com.carlos.projects.billing.dao.DocumentDAO;

/**
 * Controller to show all the existing documents
 *
 * @author Carlos Fernandez
 * @date 11-May-2012
 */
public class DocumentsController extends ParameterizableViewController {

    private DocumentDAO documentDAO;

    public DocumentsController(DocumentDAO documentDAO) {
        super();
        this.documentDAO = documentDAO;
    }

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("documents", documentDAO.findAll("Document"));
        return new ModelAndView(getViewName(), model);
    }

}