myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r673776 - in /myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces: component/UIInput.java webapp/FacesServlet.java webapp/_ErrorPageWriter.java
Date Thu, 03 Jul 2008 19:36:05 GMT
Author: lu4242
Date: Thu Jul  3 12:36:05 2008
New Revision: 673776

URL: http://svn.apache.org/viewvc?rev=673776&view=rev
Log:
MYFACES-1887 Print Multiple exceptions information thrown on update model

Modified:
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/FacesServlet.java
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java?rev=673776&r1=673775&r2=673776&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java Thu Jul
 3 12:36:05 2008
@@ -1,24 +1,24 @@
-// WARNING: This file was automatically generated. Do not edit it directly,
-//          or you will lose your changes.
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
-*/
+// WARNING: This file was automatically generated. Do not edit it directly,
+//          or you will lose your changes.
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
 package javax.faces.component;
 
 import java.util.ArrayList;
@@ -78,361 +78,360 @@
   {
     setRendererType("javax.faces.Text");
   }
-      public static final String CONVERSION_MESSAGE_ID = "javax.faces.component.UIInput.CONVERSION";
-    public static final String REQUIRED_MESSAGE_ID = "javax.faces.component.UIInput.REQUIRED";
-    public static final String UPDATE_MESSAGE_ID = "javax.faces.component.UIInput.UPDATE";
-    private static final String ERROR_HANDLING_EXCEPTION_LIST = "org.apache.myfaces.errorHandling.exceptionList";
-
-    /**
-     * Store the specified object as the "local value" of this component.
-     * The value-binding named "value" (if any) is ignored; the object is
-     * only stored locally on this component. During the "update model"
-     * phase, if there is a value-binding named "value" then this local
-     * value will be stored via that value-binding and the "local value"
-     * reset to null.
-     */
-    public void setValue(Object value)
-    {
-        setLocalValueSet(true);
-        super.setValue(value);
-    }
-
-    /**
-     * Set the "submitted value" of this component from the relevant data
-     * in the current servet request object.
-     * <p>
-     * If this component is not rendered, then do nothing; no output would
-     * have been sent to the client so no input is expected.
-     * <p>
-     * Invoke the inherited functionality, which typically invokes the
-     * renderer associated with this component to extract and set this
-     * component's "submitted value".
-     * <p>
-     * If this component is marked "immediate", then immediately apply
-     * validation to the submitted value found. On error, call context
-     * method "renderResponse" which will force processing to leap to
-     * the "render response" phase as soon as the "decode" step has
-     * completed for all other components.
-     */
-    public void processDecodes(FacesContext context)
-    {
-        if (context == null) throw new NullPointerException("context");
-        if (!isRendered()) return;
-        super.processDecodes(context);
-        if (isImmediate())
-        {
-            try
-            {
-                validate(context);
-            }
-            catch (RuntimeException e)
-            {
-                context.renderResponse();
-                throw e;
-            }
-            if (!isValid())
-            {
-                context.renderResponse();
-            }
-        }
-    }
-
-    public void processValidators(FacesContext context)
-    {
-        if (context == null) throw new NullPointerException("context");
-        if (!isRendered()) return;
-
-        super.processValidators(context);
-
-        if (!isImmediate())
-        {
-            try
-            {
-                validate(context);
-            }
-            catch (RuntimeException e)
-            {
-                context.renderResponse();
-                throw e;
-            }
-            if (!isValid())
-            {
-                context.renderResponse();
-            }
-        }
-    }
-
-    public void processUpdates(FacesContext context)
-    {
-        if (context == null) throw new NullPointerException("context");
-        if (!isRendered()) return;
-
-        super.processUpdates(context);
-
-        try
-        {
-            updateModel(context);
-        }
-        catch (RuntimeException e)
-        {
-            context.renderResponse();
-            throw e;
-        }
-        if (!isValid())
-        {
-            context.renderResponse();
-        }
-    }
-
-    public void decode(FacesContext context)
-    {
-        //We (re)set to valid, so that component automatically gets (re)validated
-        setValid(true);
-        super.decode(context);
-    }
-
-    public void broadcast(FacesEvent event)
-            throws AbortProcessingException
-    {
-        // invoke standard listeners attached to this component first
-        super.broadcast(event);
-
-        //Check if the event is applicable for ValueChangeListener
-        if (event instanceof ValueChangeEvent){
-            // invoke the single listener defined directly on the component
-            MethodBinding valueChangeListenerBinding = getValueChangeListener();
-            if (valueChangeListenerBinding != null)
-            {
-                try
-                {
-                    valueChangeListenerBinding.invoke(getFacesContext(),
-                                                      new Object[]{event});
-                }
-                catch (EvaluationException e)
-                {
-                    Throwable cause = e.getCause();
-                    if (cause != null && cause instanceof AbortProcessingException)
-                    {
-                        throw (AbortProcessingException)cause;
-                    }
-                    else
-                    {
-                        throw e;
-                    }
-                }
-            }
-        }
-    }
-
-    public void updateModel(FacesContext context)
-    {
-        if (!isValid()) return;
-        if (!isLocalValueSet()) return;
-        ValueExpression expression = getValueExpression("value");
-        if (expression == null) return;
-        try
-        {
-        	expression.setValue(context.getELContext(), getLocalValue());
-            setValue(null);
-            setLocalValueSet(false);
-        }
-        catch (Exception e)
-        {
-            context.getExternalContext().log(e.getMessage(), e);
-            _MessageUtils.addErrorMessage(context, this, UPDATE_MESSAGE_ID, new Object[]{_MessageUtils.getLabel(context,this)});
-            setValid(false);
-
-            /* we are not allowed to throw exceptions here - we still need the full stack-trace
later on
-             * to process it later in our error-handler
-             */
-            queueExceptionInRequest(context, expression, e);
-        }
-    }
-
-    /**
-     * For development and production, we want to offer a single point
-     * to which error-handlers can attach. So we queue up all ocurring
-     * exceptions and later pass them to the configured error-handler.
-     *
-     * @param context
-     * @param expression
-     * @param e
-     */
-    private void queueExceptionInRequest(FacesContext context, ValueExpression expression,
Exception e) {
-        List li = (List) context.getExternalContext().getRequestMap().get(ERROR_HANDLING_EXCEPTION_LIST);
-        if(null==li) {
-            li = new ArrayList();
-            context.getExternalContext().getRequestMap().put(ERROR_HANDLING_EXCEPTION_LIST,
li);
-
-            li.add(new FacesException("Exception while setting value for expression : "+
-                expression.getExpressionString()+" of component with path : "
-                + _ComponentUtils.getPathToComponent(this),e));
-        }
-    }
-
-    protected void validateValue(FacesContext context,Object convertedValue)
-    {
-        boolean empty = convertedValue == null ||
-                        (convertedValue instanceof String
-                         && ((String)convertedValue).length() == 0);
-
-        if (isRequired() && empty)
-        {
-        	if(getRequiredMessage() != null) {
-        		String requiredMessage = getRequiredMessage();
-        		context.addMessage(this.getClientId(context),new FacesMessage(FacesMessage.SEVERITY_ERROR,requiredMessage,requiredMessage));
-        	} else {
-        		_MessageUtils.addErrorMessage(context, this, REQUIRED_MESSAGE_ID,new Object[]{_MessageUtils.getLabel(context,this)});
-        	}
-        	setValid(false);
-        	return;
-        }
-
-        if (!empty)
-        {
-            _ComponentUtils.callValidators(context, this, convertedValue);
-        }
-
-    }
-
-    /**
-     * Determine whether the new value is valid, and queue a ValueChangeEvent
-     * if necessary.
-     * <p>
-     * The "submitted value" is converted to the necessary type; conversion
-     * failure is reported as an error and validation processing terminates
-     * for this component. See documentation for method getConvertedValue
-     * for details on the conversion process.
-     * <p>
-     * Any validators attached to this component are then run, passing
-     * the converted value.
-     * <p>
-     * The old value of this component is then fetched (possibly involving
-     * the evaluation of a value-binding expression, ie invoking a method
-     * on a user object). The old value is compared to the new validated
-     * value, and if they are different then a ValueChangeEvent is queued
-     * for later processing.
-     * <p>
-     * On successful completion of this method:
-     * <ul>
-     * <li> isValid() is true
-     * <li> isLocalValueSet() is true
-     * <li> submittedValue is reset to null
-     * <li> a ValueChangeEvent is queued if the new value != old value
-     * </ul>
-     */
-    public void validate(FacesContext context)
-    {
-        if (context == null) throw new NullPointerException("context");
-        
-        try {
-
-            Object submittedValue = getSubmittedValue();
-            if (submittedValue == null) return;
-
-            Object convertedValue = getConvertedValue(context, submittedValue);
-
-            if (!isValid()) return;
-
-            validateValue(context, convertedValue);
-
-            if (!isValid()) return;
-
-            Object previousValue = getValue();
-            setValue(convertedValue);
-            setSubmittedValue(null);
-            if (compareValues(previousValue, convertedValue))
-            {
-                queueEvent(new ValueChangeEvent(this, previousValue, convertedValue));
-            }
-        }
-        catch (Exception ex)
-        {
-            throw new FacesException("Exception while validating component with path : "+_ComponentUtils.getPathToComponent(this),ex);
-        }
-
-    }
-
-    /**
-     * Convert the provided object to the desired value.
-     * <p>
-     * If there is a renderer for this component, then call the renderer's
-     * getConvertedValue method. While this can of course be implemented in
-     * any way the renderer desires, it typically performs exactly the same
-     * processing that this method would have done anyway (ie that described
-     * below for the no-renderer case).
-     * <p>
-     * Otherwise:
-     * <ul>
-     * <li>If the submittedValue is not a String then just return the
-     *   submittedValue unconverted.
-     * <li>If there is no "value" value-binding then just return the
-     *   submittedValue unconverted.
-     * <li>Use introspection to determine the type of the target
-     *   property specified by the value-binding, and then use
-     *   Application.createConverter to find a converter that can
-     *   map from String to the required type. Apply the converter
-     *   to the submittedValue and return the result.
-     * </ul>
-     */
-    protected Object getConvertedValue(FacesContext context, Object submittedValue)
-    {
-        try
-        {
-            Renderer renderer = getRenderer(context);
-            if (renderer != null)
-            {
-                return renderer.getConvertedValue(context, this, submittedValue);
-            }
-            else if (submittedValue instanceof String)
-            {
-                Converter converter = _SharedRendererUtils.findUIOutputConverter(context,
this);
-                if (converter != null)
-                {
-                    return converter.getAsObject(context, this, (String)submittedValue);
-                }
-            }
-        }
-        catch (ConverterException e)
-        {
-        	String converterMessage = getConverterMessage();
-        	if(converterMessage != null) {
-        		context.addMessage(getClientId(context),new FacesMessage(FacesMessage.SEVERITY_ERROR,converterMessage,converterMessage));
-        	} else {
-        		 FacesMessage facesMessage = e.getFacesMessage();
-                 if (facesMessage != null)
-                 {
-                     context.addMessage(getClientId(context), facesMessage);
-                 }
-                 else
-                 {
-                     _MessageUtils.addErrorMessage(context, this, CONVERSION_MESSAGE_ID,new
Object[]{_MessageUtils.getLabel(context,this)});
-                 }
-        	}
-        	setValid(false);
-        }
-        return submittedValue;
-    }
-
-
-
-    protected boolean compareValues(Object previous,
-                                      Object value)
-    {
-        return previous==null?(value!=null):(!previous.equals(value));
-    }
-
-
-    /**
-     * @since 1.2
-     */
-    public void resetValue()
-    {
-        setSubmittedValue(null);
-        setValue(null);
-        setLocalValueSet(false);
-        setValid(true);
-    }
+      public static final String CONVERSION_MESSAGE_ID = "javax.faces.component.UIInput.CONVERSION";
+    public static final String REQUIRED_MESSAGE_ID = "javax.faces.component.UIInput.REQUIRED";
+    public static final String UPDATE_MESSAGE_ID = "javax.faces.component.UIInput.UPDATE";
+    private static final String ERROR_HANDLING_EXCEPTION_LIST = "org.apache.myfaces.errorHandling.exceptionList";
+
+    /**
+     * Store the specified object as the "local value" of this component.
+     * The value-binding named "value" (if any) is ignored; the object is
+     * only stored locally on this component. During the "update model"
+     * phase, if there is a value-binding named "value" then this local
+     * value will be stored via that value-binding and the "local value"
+     * reset to null.
+     */
+    public void setValue(Object value)
+    {
+        setLocalValueSet(true);
+        super.setValue(value);
+    }
+
+    /**
+     * Set the "submitted value" of this component from the relevant data
+     * in the current servet request object.
+     * <p>
+     * If this component is not rendered, then do nothing; no output would
+     * have been sent to the client so no input is expected.
+     * <p>
+     * Invoke the inherited functionality, which typically invokes the
+     * renderer associated with this component to extract and set this
+     * component's "submitted value".
+     * <p>
+     * If this component is marked "immediate", then immediately apply
+     * validation to the submitted value found. On error, call context
+     * method "renderResponse" which will force processing to leap to
+     * the "render response" phase as soon as the "decode" step has
+     * completed for all other components.
+     */
+    public void processDecodes(FacesContext context)
+    {
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+        super.processDecodes(context);
+        if (isImmediate())
+        {
+            try
+            {
+                validate(context);
+            }
+            catch (RuntimeException e)
+            {
+                context.renderResponse();
+                throw e;
+            }
+            if (!isValid())
+            {
+                context.renderResponse();
+            }
+        }
+    }
+
+    public void processValidators(FacesContext context)
+    {
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+
+        super.processValidators(context);
+
+        if (!isImmediate())
+        {
+            try
+            {
+                validate(context);
+            }
+            catch (RuntimeException e)
+            {
+                context.renderResponse();
+                throw e;
+            }
+            if (!isValid())
+            {
+                context.renderResponse();
+            }
+        }
+    }
+
+    public void processUpdates(FacesContext context)
+    {
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+
+        super.processUpdates(context);
+
+        try
+        {
+            updateModel(context);
+        }
+        catch (RuntimeException e)
+        {
+            context.renderResponse();
+            throw e;
+        }
+        if (!isValid())
+        {
+            context.renderResponse();
+        }
+    }
+
+    public void decode(FacesContext context)
+    {
+        //We (re)set to valid, so that component automatically gets (re)validated
+        setValid(true);
+        super.decode(context);
+    }
+
+    public void broadcast(FacesEvent event)
+            throws AbortProcessingException
+    {
+        // invoke standard listeners attached to this component first
+        super.broadcast(event);
+
+        //Check if the event is applicable for ValueChangeListener
+        if (event instanceof ValueChangeEvent){
+            // invoke the single listener defined directly on the component
+            MethodBinding valueChangeListenerBinding = getValueChangeListener();
+            if (valueChangeListenerBinding != null)
+            {
+                try
+                {
+                    valueChangeListenerBinding.invoke(getFacesContext(),
+                                                      new Object[]{event});
+                }
+                catch (EvaluationException e)
+                {
+                    Throwable cause = e.getCause();
+                    if (cause != null && cause instanceof AbortProcessingException)
+                    {
+                        throw (AbortProcessingException)cause;
+                    }
+                    else
+                    {
+                        throw e;
+                    }
+                }
+            }
+        }
+    }
+
+    public void updateModel(FacesContext context)
+    {
+        if (!isValid()) return;
+        if (!isLocalValueSet()) return;
+        ValueExpression expression = getValueExpression("value");
+        if (expression == null) return;
+        try
+        {
+        	expression.setValue(context.getELContext(), getLocalValue());
+            setValue(null);
+            setLocalValueSet(false);
+        }
+        catch (Exception e)
+        {
+            context.getExternalContext().log(e.getMessage(), e);
+            _MessageUtils.addErrorMessage(context, this, UPDATE_MESSAGE_ID, new Object[]{_MessageUtils.getLabel(context,this)});
+            setValid(false);
+
+            /* we are not allowed to throw exceptions here - we still need the full stack-trace
later on
+             * to process it later in our error-handler
+             */
+            queueExceptionInRequest(context, expression, e);
+        }
+    }
+
+    /**
+     * For development and production, we want to offer a single point
+     * to which error-handlers can attach. So we queue up all ocurring
+     * exceptions and later pass them to the configured error-handler.
+     *
+     * @param context
+     * @param expression
+     * @param e
+     */
+    private void queueExceptionInRequest(FacesContext context, ValueExpression expression,
Exception e) {
+        List li = (List) context.getExternalContext().getRequestMap().get(ERROR_HANDLING_EXCEPTION_LIST);
+        if(null==li) {
+            li = new ArrayList();
+            context.getExternalContext().getRequestMap().put(ERROR_HANDLING_EXCEPTION_LIST,
li);
+        }
+        li.add(new FacesException("Exception while setting value for expression : "+
+            expression.getExpressionString()+" of component with path : "
+            + _ComponentUtils.getPathToComponent(this),e));
+    }
+
+    protected void validateValue(FacesContext context,Object convertedValue)
+    {
+        boolean empty = convertedValue == null ||
+                        (convertedValue instanceof String
+                         && ((String)convertedValue).length() == 0);
+
+        if (isRequired() && empty)
+        {
+        	if(getRequiredMessage() != null) {
+        		String requiredMessage = getRequiredMessage();
+        		context.addMessage(this.getClientId(context),new FacesMessage(FacesMessage.SEVERITY_ERROR,requiredMessage,requiredMessage));
+        	} else {
+        		_MessageUtils.addErrorMessage(context, this, REQUIRED_MESSAGE_ID,new Object[]{_MessageUtils.getLabel(context,this)});
+        	}
+        	setValid(false);
+        	return;
+        }
+
+        if (!empty)
+        {
+            _ComponentUtils.callValidators(context, this, convertedValue);
+        }
+
+    }
+
+    /**
+     * Determine whether the new value is valid, and queue a ValueChangeEvent
+     * if necessary.
+     * <p>
+     * The "submitted value" is converted to the necessary type; conversion
+     * failure is reported as an error and validation processing terminates
+     * for this component. See documentation for method getConvertedValue
+     * for details on the conversion process.
+     * <p>
+     * Any validators attached to this component are then run, passing
+     * the converted value.
+     * <p>
+     * The old value of this component is then fetched (possibly involving
+     * the evaluation of a value-binding expression, ie invoking a method
+     * on a user object). The old value is compared to the new validated
+     * value, and if they are different then a ValueChangeEvent is queued
+     * for later processing.
+     * <p>
+     * On successful completion of this method:
+     * <ul>
+     * <li> isValid() is true
+     * <li> isLocalValueSet() is true
+     * <li> submittedValue is reset to null
+     * <li> a ValueChangeEvent is queued if the new value != old value
+     * </ul>
+     */
+    public void validate(FacesContext context)
+    {
+        if (context == null) throw new NullPointerException("context");
+        
+        try {
+
+            Object submittedValue = getSubmittedValue();
+            if (submittedValue == null) return;
+
+            Object convertedValue = getConvertedValue(context, submittedValue);
+
+            if (!isValid()) return;
+
+            validateValue(context, convertedValue);
+
+            if (!isValid()) return;
+
+            Object previousValue = getValue();
+            setValue(convertedValue);
+            setSubmittedValue(null);
+            if (compareValues(previousValue, convertedValue))
+            {
+                queueEvent(new ValueChangeEvent(this, previousValue, convertedValue));
+            }
+        }
+        catch (Exception ex)
+        {
+            throw new FacesException("Exception while validating component with path : "+_ComponentUtils.getPathToComponent(this),ex);
+        }
+
+    }
+
+    /**
+     * Convert the provided object to the desired value.
+     * <p>
+     * If there is a renderer for this component, then call the renderer's
+     * getConvertedValue method. While this can of course be implemented in
+     * any way the renderer desires, it typically performs exactly the same
+     * processing that this method would have done anyway (ie that described
+     * below for the no-renderer case).
+     * <p>
+     * Otherwise:
+     * <ul>
+     * <li>If the submittedValue is not a String then just return the
+     *   submittedValue unconverted.
+     * <li>If there is no "value" value-binding then just return the
+     *   submittedValue unconverted.
+     * <li>Use introspection to determine the type of the target
+     *   property specified by the value-binding, and then use
+     *   Application.createConverter to find a converter that can
+     *   map from String to the required type. Apply the converter
+     *   to the submittedValue and return the result.
+     * </ul>
+     */
+    protected Object getConvertedValue(FacesContext context, Object submittedValue)
+    {
+        try
+        {
+            Renderer renderer = getRenderer(context);
+            if (renderer != null)
+            {
+                return renderer.getConvertedValue(context, this, submittedValue);
+            }
+            else if (submittedValue instanceof String)
+            {
+                Converter converter = _SharedRendererUtils.findUIOutputConverter(context,
this);
+                if (converter != null)
+                {
+                    return converter.getAsObject(context, this, (String)submittedValue);
+                }
+            }
+        }
+        catch (ConverterException e)
+        {
+        	String converterMessage = getConverterMessage();
+        	if(converterMessage != null) {
+        		context.addMessage(getClientId(context),new FacesMessage(FacesMessage.SEVERITY_ERROR,converterMessage,converterMessage));
+        	} else {
+        		 FacesMessage facesMessage = e.getFacesMessage();
+                 if (facesMessage != null)
+                 {
+                     context.addMessage(getClientId(context), facesMessage);
+                 }
+                 else
+                 {
+                     _MessageUtils.addErrorMessage(context, this, CONVERSION_MESSAGE_ID,new
Object[]{_MessageUtils.getLabel(context,this)});
+                 }
+        	}
+        	setValid(false);
+        }
+        return submittedValue;
+    }
+
+
+
+    protected boolean compareValues(Object previous,
+                                      Object value)
+    {
+        return previous==null?(value!=null):(!previous.equals(value));
+    }
+
+
+    /**
+     * @since 1.2
+     */
+    public void resetValue()
+    {
+        setSubmittedValue(null);
+        setValue(null);
+        setLocalValueSet(false);
+        setValid(true);
+    }
 
   // Property: immediate
   private boolean _immediate;
@@ -872,14 +871,14 @@
     values[3] = _required;
     values[4] = _requiredSet;
     values[5] = _converterMessage;
-    values[6] = _requiredMessage;
+    values[6] = _requiredMessage;
     values[7] = saveAttachedState(facesContext, _validator);
     values[8] = saveAttachedState(facesContext, _validatorList);
     values[9] = _validatorMessage;
     values[10] = saveAttachedState(facesContext, _valueChangeListener);
     values[11] = _valid;
     values[12] = _localValueSet;
-    values[13] = _submittedValue;
+    values[13] = _submittedValue;
     
 
     return values;
@@ -895,14 +894,14 @@
     _required = (Boolean)values[3];
     _requiredSet = (Boolean)values[4];
     _converterMessage = (String)values[5];
-    _requiredMessage = (String)values[6];
+    _requiredMessage = (String)values[6];
     _validator = (MethodBinding)restoreAttachedState(facesContext, values[7]);
     _validatorList = (List<Validator>) restoreAttachedState(facesContext, values[8]);
     _validatorMessage = (String)values[9];
     _valueChangeListener = (MethodBinding)restoreAttachedState(facesContext, values[10]);
     _valid = (Boolean)values[11];
     _localValueSet = (Boolean)values[12];
-    _submittedValue = values[13];
+    _submittedValue = values[13];
   }
 
   @Override

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/FacesServlet.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/FacesServlet.java?rev=673776&r1=673775&r2=673776&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/FacesServlet.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/FacesServlet.java Thu Jul
 3 12:36:05 2008
@@ -147,9 +147,10 @@
         try {
 			_lifecycle.execute(facesContext);
 
-            handleQueuedExceptions(facesContext);
-
-            _lifecycle.render(facesContext);
+            if (!handleQueuedExceptions(facesContext))
+            {
+                _lifecycle.render(facesContext);
+            }
 		}
         catch (Exception e)
         {
@@ -174,7 +175,7 @@
      * @param facesContext
      * @throws FacesException
      */
-    private void handleQueuedExceptions(FacesContext facesContext) throws FacesException
{
+    private boolean handleQueuedExceptions(FacesContext facesContext) throws IOException,
ServletException {
         List li = (List)
                 facesContext.getExternalContext().getRequestMap().get(ERROR_HANDLING_EXCEPTION_LIST);
 
@@ -182,8 +183,43 @@
             //todo: for now, we only handle the first exception out of the list - we just
rethrow this
             //first exception.
             //in the end, we should enable the error handler to show all the exceptions at
once
-            throw (FacesException) li.get(0);
+            boolean errorHandling = getBooleanValue(facesContext.getExternalContext().getInitParameter(ERROR_HANDLING_PARAMETER),
true);
+
+            if(errorHandling) {
+                String errorHandlerClass = facesContext.getExternalContext().getInitParameter(ERROR_HANDLER_PARAMETER);
           
+                if(errorHandlerClass != null) {
+                    try {
+                        Class clazz = Class.forName(errorHandlerClass);
+
+                        Object errorHandler = clazz.newInstance();
+
+                        Method m = clazz.getMethod("handleExceptionList", new Class[]{FacesContext.class,Exception.class});
+                        m.invoke(errorHandler, new Object[]{facesContext, li});
+                    }
+                    catch(ClassNotFoundException ex) {
+                        throw new ServletException("Error-Handler : " +errorHandlerClass+
" was not found. Fix your web.xml-parameter : "+ERROR_HANDLER_PARAMETER,ex);
+                    } catch (IllegalAccessException ex) {
+                        throw new ServletException("Constructor of error-Handler : " +errorHandlerClass+
" is not accessible. Error-Handler is specified in web.xml-parameter : "+ERROR_HANDLER_PARAMETER,ex);
+                    } catch (InstantiationException ex) {
+                        throw new ServletException("Error-Handler : " +errorHandlerClass+
" could not be instantiated. Error-Handler is specified in web.xml-parameter : "+ERROR_HANDLER_PARAMETER,ex);
+                    } catch (NoSuchMethodException ex) {
+                        //Handle in the old way, since no custom method handleExceptionList
found,
+                        //throwing the first FacesException on the list.
+                        throw (FacesException) li.get(0);
+                    } catch (InvocationTargetException ex) {
+                        throw new ServletException("Excecution of method handleException
in Error-Handler : " +errorHandlerClass+ " threw an exception. Error-Handler is specified
in web.xml-parameter : "+ERROR_HANDLER_PARAMETER,ex);
+                    }
+                }
+                else {
+                    _ErrorPageWriter.handleExceptionList(facesContext, li);
+                }
+            }
+            else {
+                _ErrorPageWriter.throwException((Exception) li.get(0));
+            }
+            return true;
         }
+        return false;
     }
 
     private void handleLifecycleException(FacesContext facesContext, Exception e) throws
IOException, ServletException {

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java?rev=673776&r1=673775&r2=673776&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java Thu
Jul  3 12:36:05 2008
@@ -144,6 +144,87 @@
             }
         }
     }
+    
+    public static void debugHtml(Writer writer, FacesContext faces, List exceptionList) throws
IOException
+    {
+        init();
+        Date now = new Date();
+        for (int i = 0; i < ERROR_PARTS.length; i++)
+        {
+            if ("message".equals(ERROR_PARTS[i]))
+            {
+                for (int j = 0; j < exceptionList.size(); j++)
+                {
+                    Exception e = (Exception) exceptionList.get(j);
+                    String msg = e.getMessage();
+                    if (msg != null)
+                    {
+                        writer.write(msg.replaceAll("<", TS));
+                    }
+                    else 
+                    {
+                        writer.write(e.getClass().getName());
+                    }
+                    if (!(j+1==exceptionList.size()))
+                    {
+                        writer.write("<br>");
+                    }
+                }
+            }
+            else if ("trace".equals(ERROR_PARTS[i]))
+            {
+                for (int j = 0; j < exceptionList.size(); j++)
+                {
+                    Exception e = (Exception) exceptionList.get(j);
+                    writeException(writer, e);
+                }
+            }
+            else if ("now".equals(ERROR_PARTS[i]))
+            {
+                writer.write(DateFormat.getDateTimeInstance().format(now));
+            }
+            else if ("tree".equals(ERROR_PARTS[i]))
+            {
+                if (faces.getViewRoot() != null)
+                {
+                    List highlightId = null;
+                    for (int j = 0; j < exceptionList.size(); j++)
+                    {
+                        Exception e = (Exception) exceptionList.get(j);
+                        if (highlightId == null)
+                        {
+                            highlightId = getErrorId(e);
+                        }
+                        else
+                        {
+                            highlightId.addAll(getErrorId(e));
+                        }
+                    }
+                    writeComponent(writer, faces.getViewRoot(), highlightId);
+                }
+            }
+            else if ("vars".equals(ERROR_PARTS[i]))
+            {
+                writeVariables(writer, faces);
+            }
+            else if ("cause".equals(ERROR_PARTS[i]))
+            {
+                for (int j = 0; j < exceptionList.size(); j++)
+                {
+                    Exception e = (Exception) exceptionList.get(j);
+                    writeCause(writer, e);
+                    if (!(j+1==exceptionList.size()))
+                    {
+                        writer.write("<br>");
+                    }
+                }
+            }
+            else
+            {
+                writer.write(ERROR_PARTS[i]);
+            }
+        }
+    }    
 
     private static void writeException(Writer writer, Exception e) throws IOException {
         StringWriter str = new StringWriter(256);
@@ -357,6 +438,41 @@
             throwException(ex);
         }
     }
+    
+    public static void handleExceptionList(FacesContext facesContext, List exceptionList)
throws ServletException, IOException
+    {
+        for (int i = 0; i < exceptionList.size(); i++)
+        {
+            prepareExceptionStack( (Exception) exceptionList.get(i));
+        }
+
+        Object response = facesContext.getExternalContext().getResponse();
+        if(response instanceof HttpServletResponse)
+        {
+            HttpServletResponse httpResp = (HttpServletResponse) response;
+            if (!httpResp.isCommitted())
+            {
+                httpResp.reset();
+                httpResp.setContentType("text/html; charset=UTF-8");
+                Writer writer = httpResp.getWriter();
+
+                debugHtml(writer, facesContext, exceptionList);
+
+                for (int i = 0; i < exceptionList.size(); i++)
+                {
+                    log.error("An exception occurred", (Exception) exceptionList.get(i));
+                }
+            }
+            else
+            {
+                throwException((Exception)exceptionList.get(0));
+            }
+        }
+        else
+        {
+            throwException((Exception)exceptionList.get(0));
+        }
+    }
 
     private static void prepareExceptionStack(Throwable ex) {
 



Mime
View raw message