⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewgallerycontroller.java

📁 java写的blog
💻 JAVA
字号:
/*
 * Created on 2004-10-4
 * Author: Xuefeng, Copyright (C) 2004, Xuefeng.
 */
package org.crystalblog.web;

import java.util.*;
import javax.servlet.http.*;

import org.crystalblog.domain.*;
import org.crystalblog.logic.Facade;

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

/**
 * TO preview the images in the gallery. URL=/viewGallery.c?accountId=###&galleryId=###
 * 
 * @author Xuefeng
 */
public class ViewGalleryController implements Controller {

    private static final int IMAGES_PER_PAGE = 20;

    private SkinManager skin;
    private Facade facade;

    public void setSkinManager(SkinManager skin) { this.skin = skin; }
    public void setFacade(Facade facade) { this.facade = facade; }

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // get the category:
        int categoryId = Integer.parseInt(request.getParameter("galleryId"));
        Category category = facade.getCategory(categoryId);
        // and the account:
        Account account = facade.getAccount(category.getAccountId());
        // and the page:
        int page = 1;
        String s_page = request.getParameter("page");
        if(s_page!=null && !s_page.equals(""))
            page = Integer.parseInt(s_page);
        // get model:
        List categories = facade.getCategories(account.getAccountId());
        List links = facade.getAllLinks(account.getAccountId());
        List images = facade.getImages(categoryId, IMAGES_PER_PAGE, page);
        int total = facade.getImagesCount(categoryId);
        // create model:
        Map map = new HashMap();
        map.put("account", account);
        map.put("categories", categories);
        map.put("category", category);
        map.put("links", links);
        map.put("images", images);
        map.put("page", new Integer(page));
        int pages = total / IMAGES_PER_PAGE + (total % IMAGES_PER_PAGE == 0 ? 0 : 1);
        map.put("pages", new Integer(pages));
        return new ModelAndView(skin.getSkin(account.getSkinId()) + "gallery.html", map);
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -