Author: michiel Date: 2010-03-11 12:39:35 +0100 (Thu, 11 Mar 2010) New Revision: 41335
Modified: mmbase/trunk/applications/vpro-wizards/src/main/java/org/mmbase/applications/vprowizards/spring/ResultContainer.java Log: throw FieldError's too Modified: mmbase/trunk/applications/vpro-wizards/src/main/java/org/mmbase/applications/vprowizards/spring/ResultContainer.java =================================================================== --- mmbase/trunk/applications/vpro-wizards/src/main/java/org/mmbase/applications/vprowizards/spring/ResultContainer.java 2010-03-11 11:38:52 UTC (rev 41334) +++ mmbase/trunk/applications/vpro-wizards/src/main/java/org/mmbase/applications/vprowizards/spring/ResultContainer.java 2010-03-11 11:39:35 UTC (rev 41335) @@ -6,7 +6,7 @@ The license (Mozilla version 1.0) can be read at the MMBase site. See http://www.MMBase.org/license -*/ +*/ package org.mmbase.applications.vprowizards.spring; import java.util.*; @@ -26,19 +26,23 @@ /** * this class acts as a wrapper for everything that needs to be passed to all - * the actions that need execution for a request. + * the actions that need execution for a request. * * @author Rob Vermeulen (VPRO) * @author Ernst Bunders */ public class ResultContainer { - private List<FieldError> fieldErrors = new ArrayList<FieldError>(); - private List<GlobalError> globalErrors = new ArrayList<GlobalError>(); - private List<CacheFlushHint> cacheFlushHints = new ArrayList<CacheFlushHint>(); - private Map<String,ParamValueResolver> extraParams = new LinkedHashMap<String, ParamValueResolver>(); + private static final Logger log = Logging.getLoggerInstance(ResultContainer.class); + + // MM I prefer to compile a version where the damn errors are actually throw, so that I can at least easily see which + // damn class causes it. + private final boolean THROW = false; + private final List<FieldError> fieldErrors = new ArrayList<FieldError>(); + private final List<GlobalError> globalErrors = new ArrayList<GlobalError>(); + private final List<CacheFlushHint> cacheFlushHints = new ArrayList<CacheFlushHint>(); + private final Map<String,ParamValueResolver> extraParams = new LinkedHashMap<String, ParamValueResolver>(); private Transaction transaction = null; private Locale locale; - private static final Logger log = Logging.getLoggerInstance(ResultContainer.class); HttpServletRequest request; HttpServletResponse response; @@ -55,7 +59,7 @@ public List<FieldError> getFieldErrors() { return fieldErrors; } - + public List<GlobalError> getGlobalErrors() { return globalErrors; } @@ -69,12 +73,12 @@ public void addParamToReturnURL(String name, ParamValueResolver valueResolver){ extraParams.put(name, valueResolver); } - + /** * Add a parameter to the url the request is forwarded to. * this should be done by the {...@link ModelAndViewResolver}. * Use this method if you want to add the number of a newly created node to the - * request. This is done by the action class, but the node is only commited yet when the + * request. This is done by the action class, but the node is only commited yet when the * action is executed. So we need the node to get the number after the transaction is committed. * @param name the name of the parameter * @param node the number of this node will be the value of the param @@ -82,11 +86,12 @@ public void addParamToReturnURL(String name, final Node node){ extraParams.put(name, new ParamValueResolver(){ public String getValue() { + if (node.getNumber() < 0) throw new RuntimeException("Not a real number for node " + node + " (" + node.getCloud() + ")"); return ""+node.getNumber(); } }); } - + /** * Add a parameter to the url the request is forwarded to. * this should be done by the {...@link ModelAndViewResolver}. @@ -99,8 +104,8 @@ return value; }}); } - - + + /** * @return a map of parameters that should be added to the return request. */ @@ -111,32 +116,40 @@ } return p; } - + /** * Add a global error to this request. Global errors will cause the request to * be redirected to the error page. * @param e */ public void addGlobalError(GlobalError e){ - if(log.isDebugEnabled()){ - log.debug("adding global error: "+e); + if (THROW) { + throw e; + } else { + if (log.isDebugEnabled()){ + log.debug("adding global error: "+e); + } + globalErrors.add(e); } - globalErrors.add(e); } - + /** - * Add a field error to this request. Field errors will be displayed in the page that - * caused the error and should be displayed in this context. Mainly for validation. + * Add a field error to this request. Field errors will be displayed in the page that + * caused the error and should be displayed in this context. Mainly for validation. * @param e */ public void addFieldError(FieldError e){ - if(log.isDebugEnabled()){ - log.debug("adding field error: "+e); + if (THROW) { + throw e; + } else { + if(log.isDebugEnabled()){ + log.debug("adding field error: "+e); + } + fieldErrors.add(e); } - fieldErrors.add(e); } - + public boolean hasFieldErrors() { return !fieldErrors.isEmpty(); } @@ -180,5 +193,5 @@ return locale; } - + } _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs