Package org.magicbox.controller

Source Code of org.magicbox.controller.NavigazioneController

/*
* Copyright Massimiliano Dess'\u0355' (desmax74@yahoo.it)
*
* Licensed for non-commercial use,
* under Apache License Version 2.0
* (http://www.apache.org/licenses/LICENSE-2.0),
*
* for commercial use, under
* GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*/
package org.magicbox.controller;

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

import org.magicbox.domain.Page;
import org.magicbox.service.PagesService;
import org.magicbox.util.Constant;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
* Controller navigazione pagine esplicative
*
* @author Massimiliano Dessì (desmax74@yahoo.it)
* @since jdk 1.6.0
* @version 3.0
*/
public class NavigazioneController extends AbstractController {

    public ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse res) throws Exception {
        long id = ServletRequestUtils.getLongParameter(req, Constant.ID, 0);
        return id != 0 ? proceed(id) : notFound();
    }

    private ModelAndView proceed(long id) {
        Page page = pagesService.getPage(id);
        return page != null ? new ModelAndView("pages/dettaglioContent", Constant.CONTENT, pagesService.getPage(id)) : notFound();
    }

    private ModelAndView notFound() {
        return new ModelAndView("errors/paginaNonTrovata", "", "");
    }

    public void setPagesService(PagesService pagesService) {
        this.pagesService = pagesService;
    }

    private PagesService pagesService;
}
TOP

Related Classes of org.magicbox.controller.NavigazioneController

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.