/*
 * MosP - Mind Open Source Project    http://www.mosp.jp/
 * Copyright (C) MIND Co., Ltd.       http://www.e-mind.co.jp/
 * 
 * This program 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 2
 * of the License, or (at your option) any later version.
 * 
 * This program 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package jp.mosp.common.action;

import jp.mosp.common.common.BaseAction;
import jp.mosp.common.common.ListVo;
import jp.mosp.common.common.MospConst;
import jp.mosp.common.common.MospException;

/**
 * 一覧表示処理機能を提供する。<br><br>
 * 頁操作を行う。<br>
 */
public class PageAction extends BaseAction {
	
	/**
	 * コンストラクタ。<br>
	 * 権限確認不要設定を行う。<br>
	 */
	public PageAction() {
		super();
		setCheckAuth(false);
	}
	
	
	/**
	 * アクション。<br>
	 * 前頁、次頁ボタン押下時の処理を行う。<br>
	 */
	public void action() throws Exception {
		
		// パラメータの取得
		ListVo vo;
		try {
			vo = (ListVo)session.getAttribute(MospConst.ATT_FORMER_VO);
			if (vo == null) {
				throw new MospException(MospConst.EX_PAGE_FAILED);
			}
		} catch (ClassCastException e) {
			throw new MospException(MospConst.EX_PAGE_FAILED);
		}
		vo.initVo(cfg, msg, cmd, aspUser, user);
		
		if (cmd.equals(MospConst.CMD_LIST_SHOW)) {
			/* 処理無し */
		} else if (cmd.equals(MospConst.CMD_LIST_FORMER)) {
			vo.pageFormer();
		} else if (cmd.equals(MospConst.CMD_LIST_NEXT)) {
			vo.pageNext();
		} else {
			throw new MospException(MospConst.EX_CMD_INVALID);
		}
		setVo(vo);
		setUrl(vo.getRetUrl());
	}
	
}
