You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/07/04 00:08:44 UTC

svn commit: r673840 [2/3] - in /myfaces/core/trunk_1.2.x: api/src/main/java/javax/faces/component/ api/src/main/java/javax/faces/webapp/ api/src/test/java/javax/faces/component/ api/src/test/java/javax/faces/convert/ impl/src/main/java/org/apache/myfac...

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=673840&r1=673839&r2=673840&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 15:08:43 2008
@@ -1,549 +1,549 @@
-/*
- * 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.webapp;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.faces.context.FacesContext;
-import javax.faces.context.ExternalContext;
-import javax.faces.component.UIComponent;
-import javax.el.Expression;
-import javax.el.ValueExpression;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import java.beans.BeanInfo;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.*;
-import java.lang.reflect.Method;
-import java.text.DateFormat;
-import java.util.*;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-/**
- * @author Jacob Hookom (ICLA with ASF filed)
- */
-final class _ErrorPageWriter {
-
-    private static final Log log = LogFactory.getLog(_ErrorPageWriter.class);
-
-    private final static String TS = "<";
-
-    private static final String ERROR_TEMPLATE = "META-INF/rsc/facelet-dev-error.xml";
-
-    private static String[] ERROR_PARTS;
-
-    private static final String DEBUG_TEMPLATE = "META-INF/rsc/facelet-dev-debug.xml";
-
-    private static String[] DEBUG_PARTS;
-
-    public _ErrorPageWriter() {
-        super();
-    }
-
-    private static void init() throws IOException {
-        if (ERROR_PARTS == null) {
-            ERROR_PARTS = splitTemplate(ERROR_TEMPLATE);
-        }
-
-        if (DEBUG_PARTS == null) {
-            DEBUG_PARTS = splitTemplate(DEBUG_TEMPLATE);
-        }
-    }
-
-    private static String[] splitTemplate(String rsc) throws IOException {
-        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(rsc);
-        if (is == null) {
-            throw new FileNotFoundException(rsc);
-        }
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        byte[] buff = new byte[512];
-        int read;
-        while ((read = is.read(buff)) != -1) {
-            baos.write(buff, 0, read);
-        }
-        String str = baos.toString();
-        return str.split("@@");
-    }
-
-    private static ArrayList getErrorId(Throwable e){
-        String message = e.getMessage();
-
-        if(message==null)
-            return null;
-
-        ArrayList list = new ArrayList();
-        Pattern pattern = Pattern.compile(".*?\\Q,Id:\\E\\s*(\\S+)\\s*\\].*?");
-        Matcher matcher = pattern.matcher(message);
-
-        while (matcher.find()){
-            list.add(matcher.group(1));
-        }
-        if (list.size()>0) return list;
-        return null;
-    }
-
-    public static void writeCause(Writer writer, Throwable ex) throws IOException {
-        String msg = ex.getMessage();
-        while (ex.getCause()!=null){
-            ex=ex.getCause();
-            if (ex.getMessage()!=null) msg = ex.getMessage();
-        }
-
-        if (msg != null) {
-            msg =ex.getClass().getName() + " - " + msg;
-            writer.write(msg.replaceAll("<", TS));
-        } else {
-            writer.write(ex.getClass().getName());
-        }
-    }
-
-    public static void debugHtml(Writer writer, FacesContext faces, Throwable e) throws IOException {
-        init();
-        Date now = new Date();
-        for (int i = 0; i < ERROR_PARTS.length; i++) {
-            if ("message".equals(ERROR_PARTS[i])) {
-                String msg = e.getMessage();
-                if (msg != null) {
-                    writer.write(msg.replaceAll("<", TS));
-                } else {
-                    writer.write(e.getClass().getName());
-                }
-            } else if ("trace".equals(ERROR_PARTS[i])) {
-                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) {
-                    writeComponent(writer, faces.getViewRoot(), getErrorId(e));
-                }
-            } else if ("vars".equals(ERROR_PARTS[i])) {
-                writeVariables(writer, faces);
-            } else if ("cause".equals(ERROR_PARTS[i])) {
-                writeCause(writer, e);
-            } else {
-                writer.write(ERROR_PARTS[i]);
-            }
-        }
-    }
-    
-    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, Throwable e) throws IOException {
-        StringWriter str = new StringWriter(256);
-        PrintWriter pstr = new PrintWriter(str);
-        e.printStackTrace(pstr);
-        pstr.close();
-        writer.write(str.toString().replaceAll("<", TS));
-    }
-
-    public static void debugHtml(Writer writer, FacesContext faces) throws IOException {
-        init();
-        Date now = new Date();
-        for (int i = 0; i < DEBUG_PARTS.length; i++) {
-            if ("message".equals(DEBUG_PARTS[i])) {
-                writer.write(faces.getViewRoot().getViewId());
-            } else if ("now".equals(DEBUG_PARTS[i])) {
-                writer.write(DateFormat.getDateTimeInstance().format(now));
-            } else if ("tree".equals(DEBUG_PARTS[i])) {
-                writeComponent(writer, faces.getViewRoot(), null);
-            } else if ("vars".equals(DEBUG_PARTS[i])) {
-                writeVariables(writer, faces);
-            } else {
-                writer.write(DEBUG_PARTS[i]);
-            }
-        }
-    }
-
-    private static void writeVariables(Writer writer, FacesContext faces) throws IOException {
-        ExternalContext ctx = faces.getExternalContext();
-        writeVariables(writer, ctx.getRequestParameterMap(), "Request Parameters");
-        writeVariables(writer, ctx.getRequestMap(), "Request Attributes");
-        if (ctx.getSession(false) != null) {
-            writeVariables(writer, ctx.getSessionMap(), "Session Attributes");
-        }
-        writeVariables(writer, ctx.getApplicationMap(), "Application Attributes");
-    }
-
-    private static void writeVariables(Writer writer, Map vars, String caption) throws IOException {
-        writer.write("<table><caption>");
-        writer.write(caption);
-        writer.write("</caption><thead><tr><th style=\"width: 10%; \">Name</th><th style=\"width: 90%; \">Value</th></tr></thead><tbody>");
-        boolean written = false;
-        if (!vars.isEmpty()) {
-            SortedMap map = new TreeMap(vars);
-            Map.Entry entry = null;
-            String key = null;
-            for (Iterator itr = map.entrySet().iterator(); itr.hasNext(); ) {
-                entry = (Map.Entry) itr.next();
-                key = entry.getKey().toString();
-                if (key.indexOf('.') == -1) {
-                    writer.write("<tr><td>");
-                    writer.write(key.replaceAll("<", TS));
-                    writer.write("</td><td>");
-                    writer.write(entry.getValue().toString().replaceAll("<", TS));
-                    writer.write("</td></tr>");
-                    written = true;
-                }
-            }
-        }
-        if (!written) {
-            writer.write("<tr><td colspan=\"2\"><em>None</em></td></tr>");
-        }
-        writer.write("</tbody></table>");
-    }
-
-    private static void writeComponent(Writer writer, UIComponent c, List highlightId) throws IOException {
-        writer.write("<dl><dt");
-        if (isText(c)) {
-            writer.write(" class=\"uicText\"");
-        }
-        if (highlightId != null){
-            if ((highlightId.size() > 0) && (highlightId.get(0).equals(c.getId()))){
-                highlightId.remove(0);
-                if (highlightId.size()==0){
-                    writer.write(" class=\"highlightComponent\"");
-                }
-            }
-        }
-        writer.write(">");
-
-        boolean hasChildren = c.getChildCount() > 0 || c.getFacets().size() > 0;
-
-        writeStart(writer, c, hasChildren);
-        writer.write("</dt>");
-        if (hasChildren) {
-            if (c.getFacets().size() > 0) {
-                Map.Entry entry;
-                for (Iterator itr = c.getFacets().entrySet().iterator(); itr.hasNext(); ) {
-                    entry = (Map.Entry) itr.next();
-                    writer.write("<dd class=\"uicFacet\">");
-                    writer.write("<span>");
-                    writer.write((String) entry.getKey());
-                    writer.write("</span>");
-                    writeComponent(writer, (UIComponent) entry.getValue(), highlightId);
-                    writer.write("</dd>");
-                }
-            }
-            if (c.getChildCount() > 0) {
-                for (Iterator itr = c.getChildren().iterator(); itr.hasNext(); ) {
-                    writer.write("<dd>");
-                    writeComponent(writer, (UIComponent) itr.next(), highlightId);
-                    writer.write("</dd>");
-                }
-            }
-            writer.write("<dt>");
-            writeEnd(writer, c);
-            writer.write("</dt>");
-        }
-        writer.write("</dl>");
-    }
-
-    private static void writeEnd(Writer writer, UIComponent c) throws IOException {
-        if (!isText(c)) {
-            writer.write(TS);
-            writer.write('/');
-            writer.write(getName(c));
-            writer.write('>');
-        }
-    }
-
-    private final static String[] IGNORE = new String[] { "parent", "rendererType" };
-
-    private static void writeAttributes(Writer writer, UIComponent c) {
-        try {
-            BeanInfo info = Introspector.getBeanInfo(c.getClass());
-            PropertyDescriptor[] pd = info.getPropertyDescriptors();
-            Method m = null;
-            Object v = null;
-            String str = null;
-            for (int i = 0; i < pd.length; i++) {
-                if (pd[i].getWriteMethod() != null && Arrays.binarySearch(IGNORE, pd[i].getName()) < 0) {
-                    m = pd[i].getReadMethod();
-                    try {
-                        v = m.invoke(c, null);
-                        if (v != null) {
-                            if (v instanceof Collection || v instanceof Map || v instanceof Iterator) {
-                                continue;
-                            }
-                            writer.write(" ");
-                            writer.write(pd[i].getName());
-                            writer.write("=\"");
-                            if (v instanceof Expression) {
-                                str = ((Expression) v).getExpressionString();
-                            }
-                            writer.write(str.replaceAll("<", TS));
-                            writer.write("\"");
-                        }
-                    } catch (Exception e) {
-                        // do nothing
-                    }
-                }
-            }
-
-            ValueExpression binding = c.getValueExpression("binding");
-            if (binding != null) {
-                writer.write(" binding=\"");
-                writer.write(binding.getExpressionString().replaceAll("<", TS));
-                writer.write("\"");
-            }
-        } catch (Exception e) {
-            // do nothing
-        }
-    }
-
-    private static void writeStart(Writer writer, UIComponent c, boolean children) throws IOException {
-        if (isText(c)) {
-            String str = c.toString().trim();
-            writer.write(str.replaceAll("<", TS));
-        } else {
-            writer.write(TS);
-            writer.write(getName(c));
-            writeAttributes(writer, c);
-            if (children) {
-                writer.write('>');
-            } else {
-                writer.write("/>");
-            }
-        }
-    }
-
-    private static String getName(UIComponent c) {
-        String nm = c.getClass().getName();
-        return nm.substring(nm.lastIndexOf('.') + 1);
-    }
-
-    private static boolean isText(UIComponent c) {
-        return (c.getClass().getName().startsWith("com.sun.facelets.compiler"));
-    }
-
-    public static void handleException(FacesContext facesContext, Exception ex) throws ServletException, IOException
-    {
-        handleThrowable(facesContext, ex);
-    }
-    
-    public static void handleThrowable(FacesContext facesContext, Throwable ex) throws ServletException, IOException {
-
-        prepareExceptionStack(ex);
-
-        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, ex);
-
-                log.error("An exception occurred", ex);
-            }
-            else {
-                throwException(ex);
-            }
-        }
-        else {
-            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) {
-
-        if(ex==null)
-            return;
-
-        //check for getRootCause and getCause-methods
-        if(!initCausePerReflection(ex,"getRootCause")) {
-           initCausePerReflection(ex,"getCause");
-        }
-
-        prepareExceptionStack(ex.getCause());
-    }
-
-    private static boolean initCausePerReflection(Throwable ex, String methodName) {
-        try {
-            Method causeGetter = ex.getClass().getMethod(methodName,new Class[]{});
-            Throwable rootCause = (Throwable) causeGetter.invoke(ex,new Class[]{});
-            return initCauseIfAvailable(ex,rootCause);
-        } catch (Exception e1) {
-            return false;
-        }
-    }
-
-    static void throwException(Throwable e) throws IOException, ServletException {
-
-        prepareExceptionStack(e);
-
-        if (e instanceof IOException)
-        {
-            throw (IOException)e;
-        }
-        else if (e instanceof ServletException)
-        {
-            throw (ServletException)e;
-        }
-        else
-        {
-            ServletException ex;
-
-            if (e.getMessage() != null) {
-                ex=new ServletException(e.getMessage(), e);
-            }
-            else {
-                ex=new ServletException(e);
-            }
-
-            initCauseIfAvailable(ex, e);
-
-            throw ex;
-        }
-    }
-
-    private static boolean initCauseIfAvailable(Throwable th, Throwable cause) {
-
-        if(cause == null)
-            return false;
-
-        try {
-            Method m = Throwable.class.getMethod("initCause",new Class[]{Throwable.class});
-            m.invoke(th,new Object[]{cause});
-            return true;
-        }
-        catch(Exception e) {
-            return false;
-        }
-    }
-}
-
+/*
+ * 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.webapp;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ExternalContext;
+import javax.faces.component.UIComponent;
+import javax.el.Expression;
+import javax.el.ValueExpression;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.*;
+import java.lang.reflect.Method;
+import java.text.DateFormat;
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+/**
+ * @author Jacob Hookom (ICLA with ASF filed)
+ */
+final class _ErrorPageWriter {
+
+    private static final Log log = LogFactory.getLog(_ErrorPageWriter.class);
+
+    private final static String TS = "&lt;";
+
+    private static final String ERROR_TEMPLATE = "META-INF/rsc/facelet-dev-error.xml";
+
+    private static String[] ERROR_PARTS;
+
+    private static final String DEBUG_TEMPLATE = "META-INF/rsc/facelet-dev-debug.xml";
+
+    private static String[] DEBUG_PARTS;
+
+    public _ErrorPageWriter() {
+        super();
+    }
+
+    private static void init() throws IOException {
+        if (ERROR_PARTS == null) {
+            ERROR_PARTS = splitTemplate(ERROR_TEMPLATE);
+        }
+
+        if (DEBUG_PARTS == null) {
+            DEBUG_PARTS = splitTemplate(DEBUG_TEMPLATE);
+        }
+    }
+
+    private static String[] splitTemplate(String rsc) throws IOException {
+        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(rsc);
+        if (is == null) {
+            throw new FileNotFoundException(rsc);
+        }
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        byte[] buff = new byte[512];
+        int read;
+        while ((read = is.read(buff)) != -1) {
+            baos.write(buff, 0, read);
+        }
+        String str = baos.toString();
+        return str.split("@@");
+    }
+
+    private static ArrayList getErrorId(Throwable e){
+        String message = e.getMessage();
+
+        if(message==null)
+            return null;
+
+        ArrayList list = new ArrayList();
+        Pattern pattern = Pattern.compile(".*?\\Q,Id:\\E\\s*(\\S+)\\s*\\].*?");
+        Matcher matcher = pattern.matcher(message);
+
+        while (matcher.find()){
+            list.add(matcher.group(1));
+        }
+        if (list.size()>0) return list;
+        return null;
+    }
+
+    public static void writeCause(Writer writer, Throwable ex) throws IOException {
+        String msg = ex.getMessage();
+        while (ex.getCause()!=null){
+            ex=ex.getCause();
+            if (ex.getMessage()!=null) msg = ex.getMessage();
+        }
+
+        if (msg != null) {
+            msg =ex.getClass().getName() + " - " + msg;
+            writer.write(msg.replaceAll("<", TS));
+        } else {
+            writer.write(ex.getClass().getName());
+        }
+    }
+
+    public static void debugHtml(Writer writer, FacesContext faces, Throwable e) throws IOException {
+        init();
+        Date now = new Date();
+        for (int i = 0; i < ERROR_PARTS.length; i++) {
+            if ("message".equals(ERROR_PARTS[i])) {
+                String msg = e.getMessage();
+                if (msg != null) {
+                    writer.write(msg.replaceAll("<", TS));
+                } else {
+                    writer.write(e.getClass().getName());
+                }
+            } else if ("trace".equals(ERROR_PARTS[i])) {
+                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) {
+                    writeComponent(writer, faces.getViewRoot(), getErrorId(e));
+                }
+            } else if ("vars".equals(ERROR_PARTS[i])) {
+                writeVariables(writer, faces);
+            } else if ("cause".equals(ERROR_PARTS[i])) {
+                writeCause(writer, e);
+            } else {
+                writer.write(ERROR_PARTS[i]);
+            }
+        }
+    }
+    
+    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, Throwable e) throws IOException {
+        StringWriter str = new StringWriter(256);
+        PrintWriter pstr = new PrintWriter(str);
+        e.printStackTrace(pstr);
+        pstr.close();
+        writer.write(str.toString().replaceAll("<", TS));
+    }
+
+    public static void debugHtml(Writer writer, FacesContext faces) throws IOException {
+        init();
+        Date now = new Date();
+        for (int i = 0; i < DEBUG_PARTS.length; i++) {
+            if ("message".equals(DEBUG_PARTS[i])) {
+                writer.write(faces.getViewRoot().getViewId());
+            } else if ("now".equals(DEBUG_PARTS[i])) {
+                writer.write(DateFormat.getDateTimeInstance().format(now));
+            } else if ("tree".equals(DEBUG_PARTS[i])) {
+                writeComponent(writer, faces.getViewRoot(), null);
+            } else if ("vars".equals(DEBUG_PARTS[i])) {
+                writeVariables(writer, faces);
+            } else {
+                writer.write(DEBUG_PARTS[i]);
+            }
+        }
+    }
+
+    private static void writeVariables(Writer writer, FacesContext faces) throws IOException {
+        ExternalContext ctx = faces.getExternalContext();
+        writeVariables(writer, ctx.getRequestParameterMap(), "Request Parameters");
+        writeVariables(writer, ctx.getRequestMap(), "Request Attributes");
+        if (ctx.getSession(false) != null) {
+            writeVariables(writer, ctx.getSessionMap(), "Session Attributes");
+        }
+        writeVariables(writer, ctx.getApplicationMap(), "Application Attributes");
+    }
+
+    private static void writeVariables(Writer writer, Map vars, String caption) throws IOException {
+        writer.write("<table><caption>");
+        writer.write(caption);
+        writer.write("</caption><thead><tr><th style=\"width: 10%; \">Name</th><th style=\"width: 90%; \">Value</th></tr></thead><tbody>");
+        boolean written = false;
+        if (!vars.isEmpty()) {
+            SortedMap map = new TreeMap(vars);
+            Map.Entry entry = null;
+            String key = null;
+            for (Iterator itr = map.entrySet().iterator(); itr.hasNext(); ) {
+                entry = (Map.Entry) itr.next();
+                key = entry.getKey().toString();
+                if (key.indexOf('.') == -1) {
+                    writer.write("<tr><td>");
+                    writer.write(key.replaceAll("<", TS));
+                    writer.write("</td><td>");
+                    writer.write(entry.getValue().toString().replaceAll("<", TS));
+                    writer.write("</td></tr>");
+                    written = true;
+                }
+            }
+        }
+        if (!written) {
+            writer.write("<tr><td colspan=\"2\"><em>None</em></td></tr>");
+        }
+        writer.write("</tbody></table>");
+    }
+
+    private static void writeComponent(Writer writer, UIComponent c, List highlightId) throws IOException {
+        writer.write("<dl><dt");
+        if (isText(c)) {
+            writer.write(" class=\"uicText\"");
+        }
+        if (highlightId != null){
+            if ((highlightId.size() > 0) && (highlightId.get(0).equals(c.getId()))){
+                highlightId.remove(0);
+                if (highlightId.size()==0){
+                    writer.write(" class=\"highlightComponent\"");
+                }
+            }
+        }
+        writer.write(">");
+
+        boolean hasChildren = c.getChildCount() > 0 || c.getFacets().size() > 0;
+
+        writeStart(writer, c, hasChildren);
+        writer.write("</dt>");
+        if (hasChildren) {
+            if (c.getFacets().size() > 0) {
+                Map.Entry entry;
+                for (Iterator itr = c.getFacets().entrySet().iterator(); itr.hasNext(); ) {
+                    entry = (Map.Entry) itr.next();
+                    writer.write("<dd class=\"uicFacet\">");
+                    writer.write("<span>");
+                    writer.write((String) entry.getKey());
+                    writer.write("</span>");
+                    writeComponent(writer, (UIComponent) entry.getValue(), highlightId);
+                    writer.write("</dd>");
+                }
+            }
+            if (c.getChildCount() > 0) {
+                for (Iterator itr = c.getChildren().iterator(); itr.hasNext(); ) {
+                    writer.write("<dd>");
+                    writeComponent(writer, (UIComponent) itr.next(), highlightId);
+                    writer.write("</dd>");
+                }
+            }
+            writer.write("<dt>");
+            writeEnd(writer, c);
+            writer.write("</dt>");
+        }
+        writer.write("</dl>");
+    }
+
+    private static void writeEnd(Writer writer, UIComponent c) throws IOException {
+        if (!isText(c)) {
+            writer.write(TS);
+            writer.write('/');
+            writer.write(getName(c));
+            writer.write('>');
+        }
+    }
+
+    private final static String[] IGNORE = new String[] { "parent", "rendererType" };
+
+    private static void writeAttributes(Writer writer, UIComponent c) {
+        try {
+            BeanInfo info = Introspector.getBeanInfo(c.getClass());
+            PropertyDescriptor[] pd = info.getPropertyDescriptors();
+            Method m = null;
+            Object v = null;
+            String str = null;
+            for (int i = 0; i < pd.length; i++) {
+                if (pd[i].getWriteMethod() != null && Arrays.binarySearch(IGNORE, pd[i].getName()) < 0) {
+                    m = pd[i].getReadMethod();
+                    try {
+                        v = m.invoke(c, null);
+                        if (v != null) {
+                            if (v instanceof Collection || v instanceof Map || v instanceof Iterator) {
+                                continue;
+                            }
+                            writer.write(" ");
+                            writer.write(pd[i].getName());
+                            writer.write("=\"");
+                            if (v instanceof Expression) {
+                                str = ((Expression) v).getExpressionString();
+                            }
+                            writer.write(str.replaceAll("<", TS));
+                            writer.write("\"");
+                        }
+                    } catch (Exception e) {
+                        // do nothing
+                    }
+                }
+            }
+
+            ValueExpression binding = c.getValueExpression("binding");
+            if (binding != null) {
+                writer.write(" binding=\"");
+                writer.write(binding.getExpressionString().replaceAll("<", TS));
+                writer.write("\"");
+            }
+        } catch (Exception e) {
+            // do nothing
+        }
+    }
+
+    private static void writeStart(Writer writer, UIComponent c, boolean children) throws IOException {
+        if (isText(c)) {
+            String str = c.toString().trim();
+            writer.write(str.replaceAll("<", TS));
+        } else {
+            writer.write(TS);
+            writer.write(getName(c));
+            writeAttributes(writer, c);
+            if (children) {
+                writer.write('>');
+            } else {
+                writer.write("/>");
+            }
+        }
+    }
+
+    private static String getName(UIComponent c) {
+        String nm = c.getClass().getName();
+        return nm.substring(nm.lastIndexOf('.') + 1);
+    }
+
+    private static boolean isText(UIComponent c) {
+        return (c.getClass().getName().startsWith("com.sun.facelets.compiler"));
+    }
+
+    public static void handleException(FacesContext facesContext, Exception ex) throws ServletException, IOException
+    {
+        handleThrowable(facesContext, ex);
+    }
+    
+    public static void handleThrowable(FacesContext facesContext, Throwable ex) throws ServletException, IOException {
+
+        prepareExceptionStack(ex);
+
+        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, ex);
+
+                log.error("An exception occurred", ex);
+            }
+            else {
+                throwException(ex);
+            }
+        }
+        else {
+            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) {
+
+        if(ex==null)
+            return;
+
+        //check for getRootCause and getCause-methods
+        if(!initCausePerReflection(ex,"getRootCause")) {
+           initCausePerReflection(ex,"getCause");
+        }
+
+        prepareExceptionStack(ex.getCause());
+    }
+
+    private static boolean initCausePerReflection(Throwable ex, String methodName) {
+        try {
+            Method causeGetter = ex.getClass().getMethod(methodName,new Class[]{});
+            Throwable rootCause = (Throwable) causeGetter.invoke(ex,new Class[]{});
+            return initCauseIfAvailable(ex,rootCause);
+        } catch (Exception e1) {
+            return false;
+        }
+    }
+
+    static void throwException(Throwable e) throws IOException, ServletException {
+
+        prepareExceptionStack(e);
+
+        if (e instanceof IOException)
+        {
+            throw (IOException)e;
+        }
+        else if (e instanceof ServletException)
+        {
+            throw (ServletException)e;
+        }
+        else
+        {
+            ServletException ex;
+
+            if (e.getMessage() != null) {
+                ex=new ServletException(e.getMessage(), e);
+            }
+            else {
+                ex=new ServletException(e);
+            }
+
+            initCauseIfAvailable(ex, e);
+
+            throw ex;
+        }
+    }
+
+    private static boolean initCauseIfAvailable(Throwable th, Throwable cause) {
+
+        if(cause == null)
+            return false;
+
+        try {
+            Method m = Throwable.class.getMethod("initCause",new Class[]{Throwable.class});
+            m.invoke(th,new Object[]{cause});
+            return true;
+        }
+        catch(Exception e) {
+            return false;
+        }
+    }
+}
+

Propchange: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/webapp/_ErrorPageWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java?rev=673840&r1=673839&r2=673840&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java Thu Jul  3 15:08:43 2008
@@ -1,40 +1,40 @@
-package javax.faces.component;
-
-import javax.faces.component.html.HtmlInputText;
-
-import org.apache.shale.test.base.AbstractJsfTestCase;
-
-public class UIComponentAttributesTest extends AbstractJsfTestCase{
-  
-    public UIComponentAttributesTest(String arg0)
-    {
-        super(arg0);
-    }
-
-    private HtmlInputText input;
-    
-    
-    protected void setUp() throws Exception {
-        super.setUp();
-        input = new HtmlInputText();
-        input.setId("testId");
-    }
-
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        input = null;
-    }
-
-    public void testSetNullAttributeOnValidProperty(){
-        input.getAttributes().put("style", null);
-  }
-    public void testSetNullAttributeOnInvalidProperty(){
-        try{
-            input.getAttributes().put("someBogus", null);
-            fail("Should have thrown NullPointerException");
-        }
-        catch(NullPointerException npe){
-            //expected
-        }
-    }
+package javax.faces.component;
+
+import javax.faces.component.html.HtmlInputText;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+public class UIComponentAttributesTest extends AbstractJsfTestCase{
+  
+    public UIComponentAttributesTest(String arg0)
+    {
+        super(arg0);
+    }
+
+    private HtmlInputText input;
+    
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        input = new HtmlInputText();
+        input.setId("testId");
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        input = null;
+    }
+
+    public void testSetNullAttributeOnValidProperty(){
+        input.getAttributes().put("style", null);
+  }
+    public void testSetNullAttributeOnInvalidProperty(){
+        try{
+            input.getAttributes().put("someBogus", null);
+            fail("Should have thrown NullPointerException");
+        }
+        catch(NullPointerException npe){
+            //expected
+        }
+    }
 }
\ No newline at end of file

Propchange: myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java?rev=673840&r1=673839&r2=673840&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java Thu Jul  3 15:08:43 2008
@@ -1,141 +1,141 @@
-/*
- * Copyright 2007 The Apache Software Foundation.
- *
- * Licensed 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.convert;
-
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-
-import org.apache.shale.test.base.AbstractJsfTestCase;
-
-/**
- * This testcase test <code>javax.faces.convert.EnumConverter</code>.
- * 
- * @author Michael Kurz (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class EnumConverterTest extends AbstractJsfTestCase {
-    private enum testEnum {ITEM1, ITEM2};
-    private EnumConverter converter;
-    
-    public EnumConverterTest(String name) {
-        super(name);
-    }
-    
-    protected void setUp() throws Exception {
-        super.setUp();
-        converter = new EnumConverter(testEnum.class);
-    }
-
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        converter = null;
-    }
-
-    /**
-     * Test method for
-     * {@link javax.faces.convert.EnumConverter#getAsObject(FacesContext, javax.faces.component.UIComponent, String)}.
-     */
-    public void testGetAsObject() {
-        UIInput input = new UIInput();
-        Object convertedObj = converter.getAsObject(FacesContext.getCurrentInstance(), input, "ITEM2");
-        assertEquals(convertedObj, testEnum.ITEM2);
-    }
-
-    /**
-     * Test method for
-     * {@link javax.faces.convert.EnumConverter#getAsObject(FacesContext, javax.faces.component.UIComponent, String)}.
-     */
-    public void testGetAsObjectNull() {
-        UIInput input = new UIInput();
-           Object convertedObj = converter.getAsObject(FacesContext.getCurrentInstance(), input, null);
-           assertNull(convertedObj);
-    }
-    
-    /**
-     * Test method for
-     * {@link javax.faces.convert.EnumConverter#getAsObject(FacesContext, javax.faces.component.UIComponent, String)}.
-     */
-    public void testGetAsObjectNoEnum() {
-        UIInput input = new UIInput();
-        try {
-            converter.getAsObject(FacesContext.getCurrentInstance(), input, "NO_ENUM_CONST");
-            fail("Converter exception should be thrown");
-        } catch (ConverterException e) {
-            // should be thrown
-        }
-    }
-
-    /**
-     * Test method for
-     * {@link javax.faces.convert.EnumConverter#getAsObject(FacesContext, javax.faces.component.UIComponent, String)}.
-     */
-    public void testGetAsObjectNoClassSet() {
-        Converter testConverter = new EnumConverter();
-        UIInput input = new UIInput();
-        try {
-            testConverter.getAsObject(FacesContext.getCurrentInstance(), input, "ITEM2");
-            fail("Converter exception should be thrown");
-        } catch (ConverterException e) {
-            // should be thrown
-        }
-    }
-    
-    /**
-     * Test method for
-     * {@link javax.faces.convert.EnumConverter#getAsString(FacesContext, javax.faces.component.UIComponent, Object)}.
-     */
-    public void testGetAsString() {
-        UIInput input = new UIInput();
-        String convertedStr = converter.getAsString(FacesContext.getCurrentInstance(), input, testEnum.ITEM1);
-        assertEquals(convertedStr, testEnum.ITEM1.toString());
-    }
-
-    /**
-     * Test method for
-     * {@link javax.faces.convert.EnumConverter#getAsString(FacesContext, javax.faces.component.UIComponent, Object)}.
-     */
-    public void testGetAsStringNull() {
-        UIInput input = new UIInput();
-        String convertedStr = converter.getAsString(FacesContext.getCurrentInstance(), input, null);
-        assertEquals(convertedStr, "");
-    }
-
-    /**
-     * Test method for
-     * {@link javax.faces.convert.EnumConverter#getAsString(FacesContext, javax.faces.component.UIComponent, Object)}.
-     */
-    public void testGetAsStringNoEnum() {
-        UIInput input = new UIInput();
-        String convertedStr = converter.getAsString(FacesContext.getCurrentInstance(), input, "HALLO");
-        assertEquals(convertedStr, "HALLO");
-    }
-
-    /**
-     * Test method for
-     * {@link javax.faces.convert.EnumConverter#getAsString(FacesContext, javax.faces.component.UIComponent, Object)}.
-     */
-    public void testGetAsStringNoClassSet() {
-        Converter testConverter = new EnumConverter();
-        UIInput input = new UIInput();
-        try {
-            testConverter.getAsString(FacesContext.getCurrentInstance(), input, testEnum.ITEM1);
-            fail("Converter exception should be thrown");
-        } catch (ConverterException e) {
-            // should be thrown
-        }
-    }
-}
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * Licensed 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.convert;
+
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+/**
+ * This testcase test <code>javax.faces.convert.EnumConverter</code>.
+ * 
+ * @author Michael Kurz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class EnumConverterTest extends AbstractJsfTestCase {
+    private enum testEnum {ITEM1, ITEM2};
+    private EnumConverter converter;
+    
+    public EnumConverterTest(String name) {
+        super(name);
+    }
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        converter = new EnumConverter(testEnum.class);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        converter = null;
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.convert.EnumConverter#getAsObject(FacesContext, javax.faces.component.UIComponent, String)}.
+     */
+    public void testGetAsObject() {
+        UIInput input = new UIInput();
+        Object convertedObj = converter.getAsObject(FacesContext.getCurrentInstance(), input, "ITEM2");
+        assertEquals(convertedObj, testEnum.ITEM2);
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.convert.EnumConverter#getAsObject(FacesContext, javax.faces.component.UIComponent, String)}.
+     */
+    public void testGetAsObjectNull() {
+        UIInput input = new UIInput();
+           Object convertedObj = converter.getAsObject(FacesContext.getCurrentInstance(), input, null);
+           assertNull(convertedObj);
+    }
+    
+    /**
+     * Test method for
+     * {@link javax.faces.convert.EnumConverter#getAsObject(FacesContext, javax.faces.component.UIComponent, String)}.
+     */
+    public void testGetAsObjectNoEnum() {
+        UIInput input = new UIInput();
+        try {
+            converter.getAsObject(FacesContext.getCurrentInstance(), input, "NO_ENUM_CONST");
+            fail("Converter exception should be thrown");
+        } catch (ConverterException e) {
+            // should be thrown
+        }
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.convert.EnumConverter#getAsObject(FacesContext, javax.faces.component.UIComponent, String)}.
+     */
+    public void testGetAsObjectNoClassSet() {
+        Converter testConverter = new EnumConverter();
+        UIInput input = new UIInput();
+        try {
+            testConverter.getAsObject(FacesContext.getCurrentInstance(), input, "ITEM2");
+            fail("Converter exception should be thrown");
+        } catch (ConverterException e) {
+            // should be thrown
+        }
+    }
+    
+    /**
+     * Test method for
+     * {@link javax.faces.convert.EnumConverter#getAsString(FacesContext, javax.faces.component.UIComponent, Object)}.
+     */
+    public void testGetAsString() {
+        UIInput input = new UIInput();
+        String convertedStr = converter.getAsString(FacesContext.getCurrentInstance(), input, testEnum.ITEM1);
+        assertEquals(convertedStr, testEnum.ITEM1.toString());
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.convert.EnumConverter#getAsString(FacesContext, javax.faces.component.UIComponent, Object)}.
+     */
+    public void testGetAsStringNull() {
+        UIInput input = new UIInput();
+        String convertedStr = converter.getAsString(FacesContext.getCurrentInstance(), input, null);
+        assertEquals(convertedStr, "");
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.convert.EnumConverter#getAsString(FacesContext, javax.faces.component.UIComponent, Object)}.
+     */
+    public void testGetAsStringNoEnum() {
+        UIInput input = new UIInput();
+        String convertedStr = converter.getAsString(FacesContext.getCurrentInstance(), input, "HALLO");
+        assertEquals(convertedStr, "HALLO");
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.convert.EnumConverter#getAsString(FacesContext, javax.faces.component.UIComponent, Object)}.
+     */
+    public void testGetAsStringNoClassSet() {
+        Converter testConverter = new EnumConverter();
+        UIInput input = new UIInput();
+        try {
+            testConverter.getAsString(FacesContext.getCurrentInstance(), input, testEnum.ITEM1);
+            fail("Converter exception should be thrown");
+        } catch (ConverterException e) {
+            // should be thrown
+        }
+    }
+}

Propchange: myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/NumberConverterTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/NumberConverterTest.java?rev=673840&r1=673839&r2=673840&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/NumberConverterTest.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/NumberConverterTest.java Thu Jul  3 15:08:43 2008
@@ -1,74 +1,74 @@
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed 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.convert;
-
-import org.apache.shale.test.base.AbstractJsfTestCase;
-
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-import java.util.Locale;
-
-public class NumberConverterTest extends AbstractJsfTestCase
-{
-    private NumberConverter mock;
-
-    public static void main(String[] args)
-    {
-        junit.textui.TestRunner.run(NumberConverterTest.class);
-    }
-
-    public NumberConverterTest(String name)
-    {
-        super(name);
-    }
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-
-        mock = new NumberConverter();
-        mock.setLocale(Locale.FRANCE);
-        FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
-
-    }
-
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-
-        mock = null;
-    }
-/*
- * temporarily comment out tests that fail, until Matthias Wessendorf has time to investigate
-    public void testFranceLocaleWithNonBreakingSpace()
-    {
-
-        UIInput input = new UIInput();
-        mock.setType("currency");
-        Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "12\u00a0345,68 €");
-        assertNotNull(number);
-    }
-    public void testFranceLocaleWithoutNonBreakingSpace()
-    {
-
-        UIInput input = new UIInput();
-        mock.setType("currency");
-        Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68 €");
-        assertNotNull(number);
-    }
-*/
-}
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.convert;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import java.util.Locale;
+
+public class NumberConverterTest extends AbstractJsfTestCase
+{
+    private NumberConverter mock;
+
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(NumberConverterTest.class);
+    }
+
+    public NumberConverterTest(String name)
+    {
+        super(name);
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        mock = new NumberConverter();
+        mock.setLocale(Locale.FRANCE);
+        FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
+
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+
+        mock = null;
+    }
+/*
+ * temporarily comment out tests that fail, until Matthias Wessendorf has time to investigate
+    public void testFranceLocaleWithNonBreakingSpace()
+    {
+
+        UIInput input = new UIInput();
+        mock.setType("currency");
+        Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "12\u00a0345,68 €");
+        assertNotNull(number);
+    }
+    public void testFranceLocaleWithoutNonBreakingSpace()
+    {
+
+        UIInput input = new UIInput();
+        mock.setType("currency");
+        Number number = (Number) mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68 €");
+        assertNotNull(number);
+    }
+*/
+}

Propchange: myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/convert/NumberConverterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java?rev=673840&r1=673839&r2=673840&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java Thu Jul  3 15:08:43 2008
@@ -1,14 +1,14 @@
-package org.apache.myfaces.context.servlet;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-@Deprecated
-public final class ServletFacesContextImpl extends FacesContextImpl
-{
-    public ServletFacesContextImpl(ServletContext servletContext, ServletRequest servletRequest, ServletResponse servletResponse)
-    {
-        super(servletContext, servletRequest, servletResponse);
-    }
-}
+package org.apache.myfaces.context.servlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+@Deprecated
+public final class ServletFacesContextImpl extends FacesContextImpl
+{
+    public ServletFacesContextImpl(ServletContext servletContext, ServletRequest servletRequest, ServletResponse servletResponse)
+    {
+        super(servletContext, servletRequest, servletResponse);
+    }
+}

Propchange: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/el/unified/resolver/GuiceResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/el/unified/resolver/GuiceResolver.java?rev=673840&r1=673839&r2=673840&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/el/unified/resolver/GuiceResolver.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/el/unified/resolver/GuiceResolver.java Thu Jul  3 15:08:43 2008
@@ -1,113 +1,113 @@
-/*
- * 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 org.apache.myfaces.el.unified.resolver;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.PropertyNotFoundException;
-import javax.faces.FacesException;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.config.element.ManagedBean;
-
-import com.google.inject.Injector;
-
-/**
- * <p>Register this ELResolver in faces-config.xml.</p>
- * 
- *     &ltapplication>
- *        &ltel-resolver>org.apache.myfaces.el.unified.resolver.GuiceResolver&lt/el-resolver>
- *    &lt/application>
- *
- * <p>Implement and configure a ServletContextListener in web.xml .</p>
- * 
- *  &ltlistener>
- *      <listener-class>com.your_company.GuiceServletContextListener&lt/listener-class>
- *  &lt/listener>
- * 
- * <p>Configure Guice in your ServletContextListener implementation, and place the 
- * Injector in application scope.</p>
- * 
- * public class GuiceServletContextListener implements ServletContextListener {
- *
- *    public void contextInitialized(ServletContextEvent event) {
- *        ServletContext ctx = event.getServletContext();
- *              //when on Java6, use ServiceLoader.load(com.google.inject.Module.class);
- *        Injector injector = Guice.createInjector(new YourModule());
- *        ctx.setAttribute(GuiceResolver.KEY, injector);
- *    }
- *
- *    public void contextDestroyed(ServletContextEvent event) {
- *        ServletContext ctx = event.getServletContext();
- *        ctx.removeAttribute(GuiceResolver.KEY);
- *    }
- *
- *}
- * 
- * @author Dennis Byrne
- */
-
-public class GuiceResolver extends ManagedBeanResolver {
-
-    public static final String KEY = "oam." + Injector.class.getName();
-    
-    @Override
-    public Object getValue(ELContext ctx, Object base, Object property) 
-        throws NullPointerException, PropertyNotFoundException, ELException {
-        
-        if (base != null || !(property instanceof String)) 
-            return null;
-        
-        if (property == null)
-            throw new PropertyNotFoundException();
-        
-        FacesContext fctx = (FacesContext) ctx.getContext(FacesContext.class);
-        
-        if(fctx == null)
-            return null;
-        
-        ExternalContext ectx = fctx.getExternalContext();
-        
-        if (ectx == null || 
-            ectx.getRequestMap().containsKey(property) || 
-            ectx.getSessionMap().containsKey(property) ||
-            ectx.getApplicationMap().containsKey(property) ) 
-            return null;
-        
-        ManagedBean managedBean = runtimeConfig(ctx).getManagedBean((String)property);
-        
-        return managedBean == null ? null : getValue(ctx, ectx, managedBean.getManagedBeanClass());
-    }
-
-    private Object getValue(ELContext ctx, ExternalContext ectx, Class managedBeanClass) {
-        
-        Injector injector = (Injector) ectx.getApplicationMap().get(KEY);
-        
-        if(injector == null)
-            throw new FacesException("Could not find an instance of " + Injector.class.getName() 
-                    + " in application scope using key '" + KEY + "'");
-        
-        Object value = injector.getInstance(managedBeanClass);
-        ctx.setPropertyResolved(true);
-        return value;
-    }
-
+/*
+ * 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 org.apache.myfaces.el.unified.resolver;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.PropertyNotFoundException;
+import javax.faces.FacesException;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.config.element.ManagedBean;
+
+import com.google.inject.Injector;
+
+/**
+ * <p>Register this ELResolver in faces-config.xml.</p>
+ * 
+ *     &ltapplication>
+ *        &ltel-resolver>org.apache.myfaces.el.unified.resolver.GuiceResolver&lt/el-resolver>
+ *    &lt/application>
+ *
+ * <p>Implement and configure a ServletContextListener in web.xml .</p>
+ * 
+ *  &ltlistener>
+ *      <listener-class>com.your_company.GuiceServletContextListener&lt/listener-class>
+ *  &lt/listener>
+ * 
+ * <p>Configure Guice in your ServletContextListener implementation, and place the 
+ * Injector in application scope.</p>
+ * 
+ * public class GuiceServletContextListener implements ServletContextListener {
+ *
+ *    public void contextInitialized(ServletContextEvent event) {
+ *        ServletContext ctx = event.getServletContext();
+ *              //when on Java6, use ServiceLoader.load(com.google.inject.Module.class);
+ *        Injector injector = Guice.createInjector(new YourModule());
+ *        ctx.setAttribute(GuiceResolver.KEY, injector);
+ *    }
+ *
+ *    public void contextDestroyed(ServletContextEvent event) {
+ *        ServletContext ctx = event.getServletContext();
+ *        ctx.removeAttribute(GuiceResolver.KEY);
+ *    }
+ *
+ *}
+ * 
+ * @author Dennis Byrne
+ */
+
+public class GuiceResolver extends ManagedBeanResolver {
+
+    public static final String KEY = "oam." + Injector.class.getName();
+    
+    @Override
+    public Object getValue(ELContext ctx, Object base, Object property) 
+        throws NullPointerException, PropertyNotFoundException, ELException {
+        
+        if (base != null || !(property instanceof String)) 
+            return null;
+        
+        if (property == null)
+            throw new PropertyNotFoundException();
+        
+        FacesContext fctx = (FacesContext) ctx.getContext(FacesContext.class);
+        
+        if(fctx == null)
+            return null;
+        
+        ExternalContext ectx = fctx.getExternalContext();
+        
+        if (ectx == null || 
+            ectx.getRequestMap().containsKey(property) || 
+            ectx.getSessionMap().containsKey(property) ||
+            ectx.getApplicationMap().containsKey(property) ) 
+            return null;
+        
+        ManagedBean managedBean = runtimeConfig(ctx).getManagedBean((String)property);
+        
+        return managedBean == null ? null : getValue(ctx, ectx, managedBean.getManagedBeanClass());
+    }
+
+    private Object getValue(ELContext ctx, ExternalContext ectx, Class managedBeanClass) {
+        
+        Injector injector = (Injector) ectx.getApplicationMap().get(KEY);
+        
+        if(injector == null)
+            throw new FacesException("Could not find an instance of " + Injector.class.getName() 
+                    + " in application scope using key '" + KEY + "'");
+        
+        Object value = injector.getInstance(managedBeanClass);
+        ctx.setPropertyResolved(true);
+        return value;
+    }
+
 }
\ No newline at end of file

Propchange: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/el/unified/resolver/GuiceResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/taglib/core/PhaseListenerTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java?rev=673840&r1=673839&r2=673840&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java Thu Jul  3 15:08:43 2008
@@ -1,77 +1,77 @@
-/*
- * 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 org.apache.myfaces.util;
-
-/**
- * Utilities for determining the current container and for the unified
- * expression language.
- * 
- */
-public class ContainerUtils
-{
-    /**
-     * Determines whether we're running in a Servlet 2.5/JSP 2.1 environment.
-     * 
-     * @return <code>true</code> if we're running in a JSP 2.1 environment,
-     *         <code>false</code> otherwise
-     */
-    public static boolean isJsp21()
-    {
-        try 
-        {
-            // simply check if the class JspApplicationContext is available
-            Class.forName("javax.servlet.jsp.JspApplicationContext");
-            return true;
-        } 
-        catch (ClassNotFoundException ex) 
-        {
-            ; // expected exception in a JSP 2.0 (or less) environment
-        }
-        
-        return false;
-    }
-    
-    /**
-     * Return true if the specified string contains an EL expression.
-     * 
-     * <p>
-     * <strong>NOTICE</strong> This method is just a copy of
-     * {@link UIComponentTag#isValueReference(String)}, but it's required
-     * because the class UIComponentTag depends on a JSP 2.1 container 
-     * (for example, it indirectly implements the interface JspIdConsumer)
-     * and therefore internal classes shouldn't access this class. That's
-     * also the reason why this method is inside the class ContainerUtils,
-     * because it allows MyFaces to be independent of a JSP 2.1 container.
-     * </p>
-     */
-    public static boolean isValueReference(String value) 
-    {
-        if (value == null) {
-            throw new NullPointerException("value");
-        }
-
-        int start = value.indexOf("#{");
-        if (start < 0) {
-            return false;
-        }
-
-        int end = value.lastIndexOf('}');
-        return (end >=0 && start < end);
-    }
-}
+/*
+ * 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 org.apache.myfaces.util;
+
+/**
+ * Utilities for determining the current container and for the unified
+ * expression language.
+ * 
+ */
+public class ContainerUtils
+{
+    /**
+     * Determines whether we're running in a Servlet 2.5/JSP 2.1 environment.
+     * 
+     * @return <code>true</code> if we're running in a JSP 2.1 environment,
+     *         <code>false</code> otherwise
+     */
+    public static boolean isJsp21()
+    {
+        try 
+        {
+            // simply check if the class JspApplicationContext is available
+            Class.forName("javax.servlet.jsp.JspApplicationContext");
+            return true;
+        } 
+        catch (ClassNotFoundException ex) 
+        {
+            ; // expected exception in a JSP 2.0 (or less) environment
+        }
+        
+        return false;
+    }
+    
+    /**
+     * Return true if the specified string contains an EL expression.
+     * 
+     * <p>
+     * <strong>NOTICE</strong> This method is just a copy of
+     * {@link UIComponentTag#isValueReference(String)}, but it's required
+     * because the class UIComponentTag depends on a JSP 2.1 container 
+     * (for example, it indirectly implements the interface JspIdConsumer)
+     * and therefore internal classes shouldn't access this class. That's
+     * also the reason why this method is inside the class ContainerUtils,
+     * because it allows MyFaces to be independent of a JSP 2.1 container.
+     * </p>
+     */
+    public static boolean isValueReference(String value) 
+    {
+        if (value == null) {
+            throw new NullPointerException("value");
+        }
+
+        int start = value.indexOf("#{");
+        if (start < 0) {
+            return false;
+        }
+
+        int end = value.lastIndexOf('}');
+        return (end >=0 && start < end);
+    }
+}

Propchange: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/util/ContainerUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native