Mercurial > dive4elements > gnv-client
view gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java @ 575:a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
gnv/trunk@707 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 24 Feb 2010 14:38:36 +0000 |
parents | bd67164cf28b |
children | 9a019c125b60 |
line wrap: on
line source
package de.intevation.gnv.action; import java.util.Collection; import java.util.Iterator; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import de.intevation.gnv.action.sessionmodel.DiagrammOptions; import de.intevation.gnv.action.sessionmodel.SessionModel; import de.intevation.gnv.action.sessionmodel.SessionModelFactory; import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; import de.intevation.gnv.artifactdatabase.objects.OutputMode; import de.intevation.gnv.artifactdatabase.objects.OutputParameter; /** * @author Tim Englich <tim.englich@intevation.de> * */ public class ChangeOptionsAction extends DescribeUIAction { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(ChangeOptionsAction.class); /** * Constructor */ public ChangeOptionsAction() { super(); } @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("NextArtifactStepAction.execute"); try { SessionModel sm = SessionModelFactory.getInstance() .getSessionModel(request); ArtifactDescription ad = sm.getArtifactDescription(); String target = request.getParameter("target"); OutputMode outputMode = sm.getOutputMode(target); if (outputMode != null) { Collection<OutputParameter> op = outputMode .getOutputParameters(); if (op != null) { Iterator<OutputParameter> it = op.iterator(); DiagrammOptions diagrammOptions = new DiagrammOptions(); while (it.hasNext()) { OutputParameter parameter = it.next(); String value = request.getParameter(parameter.getName()); if (parameter.getType().equalsIgnoreCase("boolean")){ if (value == null){ value = "false"; } else { value = "true"; } } diagrammOptions.setValue(parameter.getName(),value); } sm.setDiagrammOptions(diagrammOptions); // XXX Little workarround. We should implement a 'choice' type, // if we need further choice elements! (iw) String bintype = request.getParameter("bintype"); if (bintype != null) { diagrammOptions.setValue("bintype", bintype); sm.setDiagrammOptions(diagrammOptions); request.setAttribute("bintype", bintype); } } } Map tmpOuts = ad.getOutputModes(); if (tmpOuts == null || tmpOuts.isEmpty()) { request.setAttribute("furthertargets", true); } else { request.setAttribute(target, true); } return super.execute(mapping, form, request, response); } catch (Exception e) { log.error(e, e); request.setAttribute( CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e .getMessage()); return super.getExceptionForward(mapping); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :