Java tutorial
/* * ginp - Java Web Application for Viewing Photo Collections * Copyright (C) 2004 Douglas John Culnane <doug@culnane.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */ package net.sf.ginp.commands; import net.sf.ginp.CommandParameter; import net.sf.ginp.GinpModel; import net.sf.ginp.config.Configuration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.Vector; /** * Command to change the model state to display a particular picture. * * @author Doug Culnane * @version $Revision$ */ public class ShowPicture implements Command { /** * apache Commons Logger specific to this class. */ private Log log = LogFactory.getLog(ShowPicture.class); /** * PicCollection id (colid) and path (path) should be sent in the * parameters so that the model is not out of sync with browser. * This can happen due to use of the Back Button. * * @param model Description of the Parameter * @param params Description of the Parameter */ public final void action(final GinpModel model, final Vector params) { String name = ""; String path = null; for (int i = 0; i < params.size(); i++) { CommandParameter param = (CommandParameter) params.get(i); if (param.getName().equals("name")) { name = param.getValue(); } else if (param.getName().equals("colid")) { try { int id = (new Integer(param.getValue())).intValue(); model.setCurrectCollection(id); } catch (Exception ex) { log.error(ex); } } else if (param.getName().equals("path")) { path = param.getValue(); } } if (path != null) { model.getCollection().setPath(path); } model.setCurrentPage(Configuration.getPicturePageName() + "?name=" + name); } }