myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bara...@apache.org
Subject svn commit: r544646 [1/2] - in /myfaces: core/branches/jsf12/ core/branches/jsf12/api/src/main/java/javax/faces/context/ core/branches/jsf12/impl/src/main/java/org/apache/myfaces/context/servlet/ core/branches/jsf12/impl/src/test/java/org/apache/myface...
Date Tue, 05 Jun 2007 21:51:29 GMT
Author: baranda
Date: Tue Jun  5 14:51:27 2007
New Revision: 544646

URL: http://svn.apache.org/viewvc?view=rev&rev=544646
Log:
- Fixes MYFACES-1652 (Current shared 2.0 and 3.0 should be compatible)
- Merged with parts of MyFaces core 1.1, which have been developed after branching 1.2
- Updated dependency on shale-test to 1.0.4

Added:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java
Modified:
    myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/FacesContext.java
    myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/jsp/JspViewHandlerImplTest.java
    myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLinkRendererTest.java
    myfaces/core/branches/jsf12/pom.xml
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/JavascriptUtils.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/taglib/core/SelectItemTagBase.java
    myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/util/MessageUtils.java
    myfaces/shared/branches/3_0_0/core/src/test/java/org/apache/myfaces/shared/taglib/UIComponentTagUtilsTest.java
    myfaces/shared/branches/3_0_0/core/src/test/java/org/apache/myfaces/shared/util/AbstractStateUtilsTest.java
    myfaces/shared/branches/3_0_0/core/src/test/java/org/apache/myfaces/shared/util/InitVector_CBCTestCase.java
    myfaces/shared/branches/3_0_0/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyCacheTest.java
    myfaces/shared/branches/3_0_0/core/src/test/java/org/apache/myfaces/shared/util/SecretKeyConfigurationTest.java
    myfaces/shared/branches/3_0_0/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsAES_CBCTest.java
    myfaces/shared/branches/3_0_0/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsBlowfish_ECBTest.java
    myfaces/shared/branches/3_0_0/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsDefaultTest.java
    myfaces/shared/branches/3_0_0/core/src/test/java/org/apache/myfaces/shared/util/StateUtilsTripleDES_ECBTest.java
    myfaces/shared/branches/3_0_0/pom.xml

Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/FacesContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/FacesContext.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/FacesContext.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/FacesContext.java Tue Jun  5 14:51:27 2007
@@ -33,16 +33,16 @@
     public ELContext getELContext() {
         
     	FacesContext ctx = getCurrentInstance();
-    	 
-    	if( ctx == null )
-    		throw new NullPointerException(FacesContext.class.getName());
-    	
-    	ELContext elctx = ctx.getELContext();
-    	
-    	if ( elctx == null )
-    		throw new UnsupportedOperationException();
-    	
-    	return elctx;
+
+        if (ctx == null)
+            throw new NullPointerException(FacesContext.class.getName());
+
+        ELContext elctx = ctx.getELContext();
+
+        if (elctx == null)
+            throw new UnsupportedOperationException();
+
+        return elctx;
     }
     
     public abstract javax.faces.application.Application getApplication();

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java?view=auto&rev=544646
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java (added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java Tue Jun  5 14:51:27 2007
@@ -0,0 +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);
+    }
+}

Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/jsp/JspViewHandlerImplTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/jsp/JspViewHandlerImplTest.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/jsp/JspViewHandlerImplTest.java (original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/jsp/JspViewHandlerImplTest.java Tue Jun  5 14:51:27 2007
@@ -19,27 +19,19 @@
 package org.apache.myfaces.application.jsp;
 
 import static org.apache.myfaces.Assert.assertException;
+import org.apache.myfaces.FacesTestCase;
+import org.apache.myfaces.TestRunner;
+import org.apache.myfaces.application.InvalidViewIdException;
+import org.apache.myfaces.application.ViewHandlerSupport;
 import static org.easymock.EasyMock.*;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
+import org.easymock.IAnswer;
 
 import javax.faces.application.ViewHandler;
 import javax.faces.component.UIViewRoot;
 import javax.faces.render.RenderKitFactory;
 import javax.faces.render.ResponseStateManager;
 import javax.servlet.http.HttpServletResponse;
-
-import org.apache.myfaces.FacesTestCase;
-import org.apache.myfaces.TestRunner;
-import org.apache.myfaces.application.InvalidViewIdException;
-import org.apache.myfaces.application.ViewHandlerSupport;
-import org.easymock.IAnswer;
+import java.util.*;
 
 /**
  * @author Mathias Broekelmann (latest modification by $Author$)
@@ -184,6 +176,23 @@
         expect(_externalContext.getRequestMap()).andReturn(map);
         _mocksControl.replay();
         assertEquals("xxx", _testimpl.calculateRenderKitId(_facesContext));
+        _mocksControl.verify();
+    }
+
+    /**
+     * Test method for
+     * {@link org.apache.myfaces.application.jsp.JspViewHandlerImpl#calculateLocale(javax.faces.context.FacesContext)}.
+     */
+    public void testCalculateLocaleWithNoMatchingRequestLocaleWithSupportedLocaleAndNoDefaultLocale()
+    {
+        expectApplicationAndExternalContextGet();
+        Iterator<Locale> requestLocales = Arrays.asList(new Locale[] { Locale.ENGLISH }).iterator();
+        expect(_externalContext.getRequestLocales()).andReturn(requestLocales);
+        expect(_application.getDefaultLocale()).andReturn(null);
+        Iterator<Locale> supportedLocales = Arrays.asList(new Locale[] { Locale.KOREAN }).iterator();
+        expect(_application.getSupportedLocales()).andReturn(supportedLocales);
+        _mocksControl.replay();
+        assertEquals(Locale.getDefault(), _testimpl.calculateLocale(_facesContext));
         _mocksControl.verify();
     }
 

Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLinkRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLinkRendererTest.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLinkRendererTest.java (original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlLinkRendererTest.java Tue Jun  5 14:51:27 2007
@@ -120,10 +120,10 @@
 
         String output = writer.getWriter().toString();
 
-        assertEquals("<a href=\"#\" onclick=\"clear_j_5Fid1();document.forms[&apos;j_id1&apos;].elements[&apos;j_id1:_link_hidden_&apos;]" +
-                ".value=&apos;j_id1:j_id0&apos;;if(document.forms[&apos;j_id1&apos;].onsubmit){var result=document.forms[&apos;j_id1&apos;]" +
-                ".onsubmit();  if( (typeof result == &apos;undefined&apos;) || result ) {document.forms[&apos;j_id1&apos;].submit();}}else" +
-                "{document.forms[&apos;j_id1&apos;].submit();}return false;\" " +
+        // just get what is rendered in the <a> element
+        output = output.substring(output.indexOf("<a href"));
+
+        assertEquals("<a href=\"#\" onclick=\"return oamSubmitForm(&apos;j_id1&apos;,&apos;j_id1:j_id0&apos;);\" " +
                 "accesskey=\"accesskey\" charset=\"charset\" coords=\"coords\" hreflang=\"hreflang\" " +
                 "rel=\"rel\" rev=\"rev\" shape=\"shape\" tabindex=\"tabindex\" type=\"type\" " +
                 "ondblclick=\"ondblclick\" onmousedown=\"onmousedown\" onmouseup=\"onmouseup\" " +

Modified: myfaces/core/branches/jsf12/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/pom.xml?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/core/branches/jsf12/pom.xml (original)
+++ myfaces/core/branches/jsf12/pom.xml Tue Jun  5 14:51:27 2007
@@ -214,7 +214,7 @@
       <dependency>
         <groupId>org.apache.shale</groupId>
         <artifactId>shale-test</artifactId>
-        <version>1.1.0-SNAPSHOT</version>
+        <version>1.0.4</version>
       </dependency>
       <dependency>
         <groupId>jmock</groupId>

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java Tue Jun  5 14:51:27 2007
@@ -18,8 +18,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.myfaces.shared.util.ClassUtils;
+
 import javax.faces.context.ExternalContext;
 import javax.servlet.ServletContext;
 
@@ -45,6 +45,9 @@
 
     private static final String APPLICATION_MAP_PARAM_NAME = MyfacesConfig.class.getName();
 
+    public static final String  INIT_PARAM_RESOURCE_VIRTUAL_PATH = "org.apache.myfaces.RESOURCE_VIRTUAL_PATH";
+    public static final String  INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT = "/faces/myFacesExtensionResource";
+
     private static final String  INIT_PARAM_PRETTY_HTML = "org.apache.myfaces.PRETTY_HTML";
     private static final boolean INIT_PARAM_PRETTY_HTML_DEFAULT = true;
 
@@ -62,43 +65,80 @@
 
     private static final String  INIT_CHECK_EXTENSIONS_FILTER = "org.apache.myfaces.CHECK_EXTENSIONS_FILTER";
     private static final boolean INIT_CHECK_EXTENSIONS_FILTER_DEFAULT = true;
-    
+
+    private static final String INIT_READONLY_AS_DISABLED_FOR_SELECT = "org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS";
+    private static final boolean INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT = true;
+
+
     private boolean _prettyHtml;
     private boolean _detectJavascript;
     private boolean _allowJavascript;
     private boolean _autoScroll;
     private String _addResourceClass;
+    private String _resourceVirtualPath;
     private boolean _checkExtensionsFilter;
+    private boolean _readonlyAsDisabledForSelect;
 
     private static final boolean TOMAHAWK_AVAILABLE;
-    
+    private static final boolean MYFACES_IMPL_AVAILABLE;
+    private static final boolean RI_IMPL_AVAILABLE;
+
+    static
+    {
+        boolean tomahawkAvailable;
+        try
+        {
+            ClassUtils.classForName("org.apache.myfaces.webapp.filter.ExtensionsFilter");
+            tomahawkAvailable = true;
+        }
+        catch (ClassNotFoundException e)
+        {
+            tomahawkAvailable = false;
+        }
+        TOMAHAWK_AVAILABLE = tomahawkAvailable;
+    }
+
+    static
+    {
+        boolean myfacesImplAvailable;
+        try
+        {
+            ClassUtils.classForName("org.apache.myfaces.application.ApplicationImpl");
+            myfacesImplAvailable = true;
+        }
+        catch (ClassNotFoundException e)
+        {
+            myfacesImplAvailable = false;
+        }
+        MYFACES_IMPL_AVAILABLE = myfacesImplAvailable;
+    }
+
     static
     {
-    	boolean tomahawkAvailable;
-    	try
-		{
-			ClassUtils
-					.classForName("org.apache.myfaces.webapp.filter.ExtensionsFilter");
-			tomahawkAvailable = true;
-		}
-		catch (ClassNotFoundException e)
-		{
-			tomahawkAvailable = false;
-		}
-		TOMAHAWK_AVAILABLE = tomahawkAvailable;
+        boolean riImplAvailable;
+        try
+        {
+            ClassUtils.classForName("com.sun.faces.application.ApplicationImpl");
+            riImplAvailable = true;
+        }
+        catch (ClassNotFoundException e)
+        {
+            riImplAvailable = false;
+        }
+        RI_IMPL_AVAILABLE = riImplAvailable;
     }
-    
+
     public static MyfacesConfig getCurrentInstance(ExternalContext extCtx)
     {
-        MyfacesConfig myfacesConfig = (MyfacesConfig)extCtx
-                                        .getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
+        MyfacesConfig myfacesConfig = (MyfacesConfig) extCtx
+                .getApplicationMap().get(APPLICATION_MAP_PARAM_NAME);
         if (myfacesConfig == null)
         {
-        	
-        	myfacesConfig = createAndInitializeMyFacesConfig(extCtx);
-        	
-        	extCtx.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, myfacesConfig);
-        	
+
+            myfacesConfig = createAndInitializeMyFacesConfig(extCtx);
+
+            extCtx.getApplicationMap().put(APPLICATION_MAP_PARAM_NAME, myfacesConfig);
+
         }
 
         return myfacesConfig;
@@ -112,16 +152,23 @@
                                                             INIT_PARAM_PRETTY_HTML_DEFAULT));
         myfacesConfig.setAllowJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_ALLOW_JAVASCRIPT,
                                                                  INIT_PARAM_ALLOW_JAVASCRIPT_DEFAULT));
+
+        myfacesConfig.setReadonlyAsDisabledForSelect(getBooleanInitParameter(extCtx, INIT_READONLY_AS_DISABLED_FOR_SELECT,
+                                                                 INIT_READONLY_AS_DISABLED_FOR_SELECT_DEFAULT));
+
         if (TOMAHAWK_AVAILABLE)
         {
             myfacesConfig.setDetectJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_DETECT_JAVASCRIPT,
-                INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT));
-	        myfacesConfig.setAutoScroll(getBooleanInitParameter(extCtx, INIT_PARAM_AUTO_SCROLL,
-	                INIT_PARAM_AUTO_SCROLL_DEFAULT));
-	        myfacesConfig.setAddResourceClass(getStringInitParameter(extCtx, INIT_PARAM_ADD_RESOURCE_CLASS,
-	                                                                 INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT));
-	        myfacesConfig.setCheckExtensionsFilter(getBooleanInitParameter(extCtx, INIT_CHECK_EXTENSIONS_FILTER,
-	        		INIT_CHECK_EXTENSIONS_FILTER_DEFAULT));
+                    INIT_PARAM_DETECT_JAVASCRIPT_DEFAULT));
+            myfacesConfig.setAutoScroll(getBooleanInitParameter(extCtx, INIT_PARAM_AUTO_SCROLL,
+                    INIT_PARAM_AUTO_SCROLL_DEFAULT));
+            myfacesConfig.setAddResourceClass(getStringInitParameter(extCtx, INIT_PARAM_ADD_RESOURCE_CLASS,
+                    INIT_PARAM_ADD_RESOURCE_CLASS_DEFAULT));
+            myfacesConfig.setResourceVirtualPath(getStringInitParameter(extCtx, INIT_PARAM_RESOURCE_VIRTUAL_PATH,
+                    INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT));
+
+            myfacesConfig.setCheckExtensionsFilter(getBooleanInitParameter(extCtx, INIT_CHECK_EXTENSIONS_FILTER,
+                    INIT_CHECK_EXTENSIONS_FILTER_DEFAULT));
         }
         else
         {
@@ -130,6 +177,27 @@
             	log.info("Tomahawk jar not available. Autoscrolling, DetectJavascript, AddResourceClass and CheckExtensionsFilter are disabled now.");
             }
         }
+
+        if(RI_IMPL_AVAILABLE)
+        {
+            if(log.isInfoEnabled())
+            {
+                log.info("Starting up Tomahawk on the RI-JSF-Implementation.");
+            }
+        }
+
+        if(MYFACES_IMPL_AVAILABLE)
+        {
+            if(log.isInfoEnabled())
+            {
+                log.info("Starting up Tomahawk on the MyFaces-JSF-Implementation");
+            }
+        }
+
+        if(RI_IMPL_AVAILABLE && MYFACES_IMPL_AVAILABLE)
+        {
+            log.error("Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations.");
+        }
 		return myfacesConfig;
 	}
 
@@ -170,9 +238,18 @@
         }
         
         return strValue;
+    }
         
+     private void setResourceVirtualPath( String resourceVirtualPath )
+     {
+         this._resourceVirtualPath = resourceVirtualPath;
     }
 
+     public String getResourceVirtualPath()
+     {
+         return this._resourceVirtualPath;
+     }
+
     public boolean isPrettyHtml()
     {
         return _prettyHtml;
@@ -191,6 +268,31 @@
     private void setDetectJavascript(boolean detectJavascript)
     {
         _detectJavascript = detectJavascript;
+    }
+
+    private void setReadonlyAsDisabledForSelect(boolean readonlyAsDisabledForSelect)
+    {
+        _readonlyAsDisabledForSelect = readonlyAsDisabledForSelect;
+    }
+
+    public boolean isReadonlyAsDisabledForSelect()
+    {
+        return _readonlyAsDisabledForSelect;
+    }
+
+    public boolean isTomahawkAvailable()
+    {
+        return TOMAHAWK_AVAILABLE;
+    }
+
+    public boolean isMyfacesImplAvailable()
+    {
+        return MYFACES_IMPL_AVAILABLE;
+    }
+
+    public boolean isRiImplAvailable()
+    {
+        return RI_IMPL_AVAILABLE;
     }
 
     /**

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java Tue Jun  5 14:51:27 2007
@@ -29,6 +29,7 @@
     String   ID_ATTR                        = "id";
     String   VALUE_ATTR                     = "value";
     String   BINDING_ATTR                   = "binding";
+    String   STYLE_ATTR                     = "style";
     String   STYLE_CLASS_ATTR               = "styleClass";
     String   ESCAPE_ATTR                    = "escape";
     String   FORCE_ID_ATTR                  = "forceId";

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java Tue Jun  5 14:51:27 2007
@@ -17,9 +17,11 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
 import org.apache.myfaces.shared.util.HashMapUtils;
 import org.apache.myfaces.shared.util.SelectItemsIterator;
 
+import javax.el.ValueExpression;
 import javax.faces.FacesException;
 import javax.faces.FactoryFinder;
 import javax.faces.component.*;
@@ -189,6 +191,27 @@
         return ((ValueHolder)component).getValue();
     }
 
+    @Deprecated
+    public static String getStringValue(FacesContext context, ValueBinding vb)
+    {
+        Object value = vb.getValue(context);
+        if (value != null)
+        {
+            return value.toString();
+        }
+        return null;
+    }
+
+    public static String getStringValue(FacesContext context, ValueExpression ve)
+    {
+        Object value = ve.getValue(context.getELContext());
+        if (value != null)
+        {
+            return value.toString();
+        }
+        return null;
+    }
+
     public static String getStringValue(FacesContext facesContext,
                                         UIComponent component)
     {
@@ -329,10 +352,10 @@
         if (converter != null) return converter;
 
         //Try to find out by value binding
-        ValueBinding vb = component.getValueBinding("value");
+        ValueExpression vb = component.getValueExpression("value");
         if (vb == null) return null;
 
-        Class valueType = vb.getType(facesContext);
+        Class valueType = vb.getType(facesContext.getELContext());
         if (valueType == null) return null;
 
         if (List.class.isAssignableFrom(valueType))
@@ -373,6 +396,7 @@
         }
 
         Class arrayComponentType = valueType.getComponentType();
+        if (String.class.equals(arrayComponentType)) return null;    //No converter needed for String type
         if (Object.class.equals(arrayComponentType)) return null;    //There is no converter for Object class
 
         try
@@ -495,6 +519,10 @@
             return null;
         }
 
+        if(converter != null) {
+            converter = new PassThroughAsStringConverter(converter);
+        }
+
         return internalSubmittedOrSelectedValuesAsSet(context, component, converter, uiSelectMany, submittedValues);
     }
 
@@ -666,23 +694,72 @@
         return i != null ? i.intValue() : defaultValue;
     }
 
-    public static UIForm findParentForm(UIComponentBase comp)
+    private static final String TRINIDAD_FORM_COMPONENT_FAMILY = "org.apache.myfaces.trinidad.Form";
+    private static final String ADF_FORM_COMPONENT_FAMILY = "oracle.adf.Form";
+
+
+    /**
+     * Find the enclosing form of a component
+     * in the view-tree.
+     * All Subclasses of <code>UIForm</code> and all known
+     * form-families are searched for.
+     * Currently those are the Trinidad form family,
+     * and the (old) ADF Faces form family.
+     * <p/>
+     * There might be additional form families
+     * which have to be explicitly entered here.
+     *
+     * @param uiComponent
+     * @param facesContext
+     * @return FormInfo Information about the form - the form itself and its name.
+     */
+    public static FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
     {
-        UIComponent parent = comp.getParent();
-        while (parent != null)
+        UIComponent parent = uiComponent.getParent();
+        while (parent != null && (!ADF_FORM_COMPONENT_FAMILY.equals(parent.getFamily()) &&
+            !TRINIDAD_FORM_COMPONENT_FAMILY.equals(parent.getFamily()) &&
+            !(parent instanceof UIForm)))
         {
-            if (parent instanceof UIForm)
-            {
-                return (UIForm) parent;
-            }
             parent = parent.getParent();
         }
+
+        if (parent != null)
+        {
+            //link is nested inside a form
+            String formName = parent.getClientId(facesContext);
+            return new FormInfo(parent, formName);
+        }
+
         return null;
     }
 
+    public static boolean getBooleanValue(String attribute, Object value, boolean defaultValue) {
+        if (value instanceof Boolean) {
+            return ((Boolean) value).booleanValue();
+        }
+        else if (value instanceof String) {
+            return Boolean.valueOf((String) value).booleanValue();
+        }
+        else if (value != null) {
+            log.error("value for attribute " + attribute +
+                " must be instanceof 'Boolean' or 'String', is of type : " + value.getClass());
+
+            return defaultValue;
+        }
+
+        return defaultValue;
+    }
+
     public static void copyHtmlInputTextAttributes(HtmlInputText src, HtmlInputText dest)
     {
         dest.setId(src.getId());
+        boolean forceId = getBooleanValue(
+            JSFAttr.FORCE_ID_ATTR,
+            src.getAttributes().get(JSFAttr.FORCE_ID_ATTR),
+            false);
+        if (forceId) {
+            dest.getAttributes().put(JSFAttr.FORCE_ID_ATTR, Boolean.TRUE);
+        }
         dest.setImmediate(src.isImmediate());
         dest.setTransient(src.isTransient());
         dest.setAccesskey(src.getAccesskey());
@@ -860,50 +937,60 @@
      * @param file name of the resource file (e.g. <code>foo.css</code>).
      * @return the content of the resource file, or <code>null</code> if no such file is available.
      */
-    public static Object loadResourceFile(FacesContext ctx, String file)
+    public static String loadResourceFile(FacesContext ctx, String file)
     {
 
-        String href = ctx.getExternalContext().getRequestContextPath() + file;
-        if (log.isDebugEnabled())
-            log.debug("loadFile: " + href);
+        ByteArrayOutputStream content = new ByteArrayOutputStream(10240);
 
-        File resourceFile = new File(href);
-        String content;
+		InputStream in = null;
+		try {
+			in = ctx.getExternalContext().getResourceAsStream(file);
+			if (in == null)
+			{
+				return null;
+			}
+
+			byte[] fileBuffer = new byte[10240];
+			int read;
+			while ((read = in.read(fileBuffer)) > -1)
+			{
+				content.write(fileBuffer, 0, read);
+			}
+		}
+		catch (FileNotFoundException e) {
+			if (log.isWarnEnabled())
+				log.warn("no such file " + file, e);
+			content = null;
+		}
+		catch (IOException e) {
+			if (log.isWarnEnabled())
+				log.warn("problems during processing resource " + file, e);
+			content = null;
+		}
+		finally
+		{
+			try
+			{
+				content.close();
+			}
+			catch (IOException e)
+			{
+				log.warn(e.getLocalizedMessage(), e);
+			}
+			if (in != null)
+			{
+				try
+				{
+					in.close();
+				}
+				catch (IOException e)
+				{
+					log.warn(e.getLocalizedMessage(), e);
+				}
+			}
+		}
 
-        if (resourceFile.canRead())
-        {
-            FileInputStream in;
-            try
-            {
-                in = new FileInputStream(resourceFile);
-                byte[] fileBuffer = new byte[(int) resourceFile.length()];
-                in.read(fileBuffer);
-                in.close();
-                content = new String(fileBuffer);
-            }
-            catch (FileNotFoundException e)
-            {
-                if (log.isWarnEnabled())
-                    log.warn("no such file", e);
-                content = null;
-            }
-            catch (IOException e)
-            {
-                if (log.isWarnEnabled())
-                    log.warn("problems during writing file", e);
-                e.printStackTrace();
-                content = null;
-            }
-
-        }
-        else
-        {
-            if (log.isErrorEnabled())
-                log.error("File not readable: " + href);
-            content = null;
-        }
-
-        return content;
+		return content.toString();
     }
 
     /**
@@ -932,6 +1019,14 @@
         }
     }
 
+    public static boolean isAdfOrTrinidadForm(UIComponent component) {
+        if (component == null)
+            return false;
+        return ADF_FORM_COMPONENT_FAMILY.equals(component.getFamily()) ||
+            TRINIDAD_FORM_COMPONENT_FAMILY.equals(component.getFamily());
+    }
+
+
     /**
      * Gets the ResponseStateManager for the renderKit Id provided
      */
@@ -965,5 +1060,34 @@
             }
         }
         return renderKit.getResponseStateManager();
+    }
+
+    /**
+     * Special converter for handling submitted values which don't need to be converted.
+     *
+     * @author mathias (latest modification by $Author$)
+     * @version $Revision$ $Date$
+     */
+    private static class PassThroughAsStringConverter implements Converter
+    {
+        private final Converter converter;
+
+        public PassThroughAsStringConverter(Converter converter)
+        {
+            this.converter = converter;
+        }
+
+        public Object getAsObject(FacesContext context, UIComponent component,
+                String value) throws ConverterException
+        {
+            return converter.getAsObject(context, component, value);
+        }
+
+        public String getAsString(FacesContext context, UIComponent component,
+                Object value) throws ConverterException
+        {
+            return (String)value;
+        }
+
     }
 }

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HTML.java Tue Jun  5 14:51:27 2007
@@ -26,12 +26,17 @@
  */
 public interface HTML
 {
+    // Deprecated attributes
+    @Deprecated String DATAFLD_ATTR = "datafld";
+    @Deprecated String DATASRC_ATTR = "datasrc";
+    @Deprecated String DATAFORMATAS_ATTR = "dataformatas";
 
     // Common attributes
     String ALIGN_ATTR = "align";
     String BORDER_ATTR = "border";
     String WIDTH_ATTR = "width";
     String READONLY_ATTR = "readonly";
+    String FILE_ATTR = "file";
     String ACCEPT_ATTR = "accept";
 
     // Common event handler attributes

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java Tue Jun  5 14:51:27 2007
@@ -15,8 +15,11 @@
  */
 package org.apache.myfaces.shared.renderkit.html;
 
-import java.io.IOException;
-import java.util.Map;
+import org.apache.myfaces.shared.config.MyfacesConfig;
+import org.apache.myfaces.shared.renderkit.JSFAttr;
+import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
+import org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils;
 
 import javax.faces.component.UICommand;
 import javax.faces.component.UIComponent;
@@ -26,12 +29,8 @@
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import javax.faces.event.ActionEvent;
-
-import org.apache.myfaces.shared.config.MyfacesConfig;
-import org.apache.myfaces.shared.renderkit.JSFAttr;
-import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
-import org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils;
-import org.apache.myfaces.shared.util._ComponentUtils;
+import java.io.IOException;
+import java.util.Map;
 
 
 /**
@@ -137,7 +136,8 @@
             writer.writeAttribute(HTML.READONLY_ATTR, Boolean.TRUE, org.apache.myfaces.shared.renderkit.JSFAttr.READONLY_ATTR);
         }
 
-        writer.endElement(HTML.INPUT_ELEM);
+        HtmlFormRendererBase.renderScrollHiddenInputIfNecessary(
+            findNestingForm(uiComponent, facesContext).getForm(), facesContext, writer);
     }
 
 
@@ -188,18 +188,21 @@
             onClick.append(';');
         }
 
-        //call the clear_<formName> method
-        onClick.append(HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName)).append("();");
+        //call the script to clear the form (clearFormHiddenParams_<formName>) method
+        HtmlRendererUtils.appendClearHiddenCommandFormParamsFunctionCall(onClick, formName);
 
-        if (MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isAutoScroll())
-        {
-            org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils.appendAutoScrollAssignment(onClick, formName);
+        if (MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isAutoScroll()) {
+            HtmlRendererUtils.appendAutoScrollAssignment(onClick, formName);
         }
 
         //add hidden field for the case there is no commandLink in the form
-        String hiddenFieldName = HtmlRendererUtils.getHiddenCommandLinkFieldName(formName);
+        String hiddenFieldName = HtmlRendererUtils.getHiddenCommandLinkFieldName(formInfo);
         addHiddenCommandParameter(facesContext, nestingForm, hiddenFieldName);
 
+        //add hidden field for the case there is no commandLink in the form
+        String hiddenFieldNameMyFacesOld = HtmlRendererUtils.getHiddenCommandLinkFieldNameMyfacesOld(formInfo);
+        addHiddenCommandParameter(facesContext, nestingForm, hiddenFieldNameMyFacesOld);
+
         return onClick;
     }
 
@@ -207,7 +210,7 @@
 	{
 		if (nestingForm != null)
         {
-            HtmlFormRendererBase.addHiddenCommandParameter(nestingForm, hiddenFieldName);
+            HtmlFormRendererBase.addHiddenCommandParameter(facesContext, nestingForm, hiddenFieldName);
         }
 	}
 
@@ -217,7 +220,7 @@
      */
     protected FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
     {
-    	return _ComponentUtils.findNestingForm(uiComponent, facesContext);
+        return RendererUtils.findNestingForm(uiComponent, facesContext);
     }
 
     protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java Tue Jun  5 14:51:27 2007
@@ -46,6 +46,7 @@
     private static final String HIDDEN_COMMAND_INPUTS_SET_ATTR
             = UIForm.class.getName() + ".org.apache.myfaces.HIDDEN_COMMAND_INPUTS_SET";
 
+    private static final String SCROLL_HIDDEN_INPUT = "org.apache.myfaces.SCROLL_HIDDEN_INPUT";
 
     public void encodeBegin(FacesContext facesContext, UIComponent component)
             throws IOException
@@ -81,6 +82,17 @@
         afterFormElementsStart(facesContext, component);
     }
 
+    protected String getActionUrl(FacesContext facesContext, UIForm form) {
+        return getActionUrl(facesContext);
+    }
+
+    protected String getMethod(FacesContext facesContext, UIForm form) {
+        return "post";
+    }
+
+    protected String getAcceptCharset(FacesContext facesContext, UIForm form ) {
+    	return (String)form.getAttributes().get( JSFAttr.ACCEPTCHARSET_ATTR );
+    }
 
     public void encodeEnd(FacesContext facesContext, UIComponent component)
             throws IOException
@@ -118,11 +130,8 @@
         writer.writeAttribute(HTML.VALUE_ATTR, HIDDEN_SUBMIT_INPUT_VALUE, null);
         writer.endElement(HTML.INPUT_ELEM);
 
-        if (MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isAutoScroll())
-        {
-            org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils.renderAutoScrollHiddenInput(facesContext,writer);
-        }
-        
+        renderScrollHiddenInputIfNecessary(component, facesContext, writer);
+
         if(!facesContext.getApplication().getStateManager().isSavingStateInClient(facesContext))
         {
             writer.startElement(HTML.INPUT_ELEM, component);
@@ -142,6 +151,22 @@
         writer.endElement(HTML.FORM_ELEM);
     }
 
+    private static String getHiddenCommandInputsSetName(FacesContext facesContext, UIComponent form) {
+        StringBuffer buf = new StringBuffer();
+        buf.append(HIDDEN_COMMAND_INPUTS_SET_ATTR);
+        buf.append("_");
+        buf.append(form.getClientId(facesContext));
+        return buf.toString();
+    }
+
+    private static String getScrollHiddenInputName(FacesContext facesContext, UIComponent form) {
+        StringBuffer buf = new StringBuffer();
+        buf.append(SCROLL_HIDDEN_INPUT);
+        buf.append("_");
+        buf.append(form.getClientId(facesContext));
+        return buf.toString();
+    }
+
 
     public void decode(FacesContext facesContext, UIComponent component)
     {
@@ -170,15 +195,30 @@
     }
 
 
-    public static void addHiddenCommandParameter(UIComponent form, String paramName)
+    public static void addHiddenCommandParameter(FacesContext facesContext, UIComponent form, String paramName)
     {
-        Set set = (Set)form.getAttributes().get(HIDDEN_COMMAND_INPUTS_SET_ATTR);
+        Set set = (Set) facesContext.getExternalContext().getRequestMap().get(getHiddenCommandInputsSetName(facesContext, form));
         if (set == null)
         {
             set = new HashSet();
-            form.getAttributes().put(HIDDEN_COMMAND_INPUTS_SET_ATTR, set);
+            facesContext.getExternalContext().getRequestMap().put(getHiddenCommandInputsSetName(facesContext, form), set);
         }
         set.add(paramName);
+    }
+
+    public static void renderScrollHiddenInputIfNecessary(UIComponent form, FacesContext facesContext, ResponseWriter writer)
+        throws IOException {
+        if (form == null) {
+            return;
+        }
+
+        if (facesContext.getExternalContext().getRequestMap().get(getScrollHiddenInputName(facesContext, form)) == null)
+        {
+            if (MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isAutoScroll()) {
+                HtmlRendererUtils.renderAutoScrollHiddenInput(facesContext, writer);
+            }
+            facesContext.getExternalContext().getRequestMap().put(getScrollHiddenInputName(facesContext, form), Boolean.TRUE);
+        }
     }
 
     private String getAcceptCharset(UIComponent uiComponent)

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java Tue Jun  5 14:51:27 2007
@@ -15,7 +15,6 @@
  */
 package org.apache.myfaces.shared.renderkit.html;
 
-import org.apache.myfaces.shared.config.MyfacesConfig;
 import org.apache.myfaces.shared.renderkit.JSFAttr;
 import org.apache.myfaces.shared.renderkit.RendererUtils;
 import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
@@ -63,7 +62,9 @@
         if (component instanceof UICommand)
         {
             String clientId = component.getClientId(facesContext);
-            String reqValue = (String)facesContext.getExternalContext().getRequestParameterMap().get(HtmlRendererUtils.getHiddenCommandLinkFieldName(findNestingForm(component, facesContext).getFormName()));
+            FormInfo formInfo = findNestingForm(component, facesContext);
+            String reqValue = (String) facesContext.getExternalContext().getRequestParameterMap().get(
+                HtmlRendererUtils.getHiddenCommandLinkFieldName(formInfo));
             if (reqValue != null && reqValue.equals(clientId))
             {
                 component.queueEvent(new ActionEvent(component));
@@ -145,6 +146,9 @@
         if (component instanceof UICommand)
         {
                 renderCommandLinkEnd(facesContext, component);
+
+            HtmlFormRendererBase.renderScrollHiddenInputIfNecessary(
+                findNestingForm(component, facesContext).getForm(), facesContext, facesContext.getResponseWriter());
         }
         else if (component instanceof UIOutput)
         {
@@ -212,10 +216,11 @@
     	if (formInfo == null)
     	{
             String path = RendererUtils.getPathToComponent(component);
-            String msg = "Change component/tag '" + clientId + "' from javax.faces.*/<h:tagName /> " +
-                    "to org.apache.myfaces.*/<t:tagName />, or embed it in a form.  This is not a bug. " +
-                    "Please see: http://wiki.apache.org/myfaces/Upgrading_to_Tomahawk_1.1.3 " +
-                    "The path to this component is " + path ;
+            String msg = "Link is not embedded in a form. Change component/tag '" + clientId + "' from javax.faces.*/<h:tagName /> " +
+                "to org.apache.myfaces.*/<t:tagName />, or embed it in a form.  This is not a bug. " +
+                "Please see: http://wiki.apache.org/myfaces/Upgrading_to_Tomahawk_1.1.3 " +
+                "The path to this component is " + path + ". If you need to render a special form and a JSF-form's attributes are not enough," +
+                "consider using the s:form tag of the MyFaces sandbox.";
     		throw new IllegalArgumentException(msg);
     	}
     	UIComponent nestingForm = formInfo.getForm();
@@ -238,66 +243,94 @@
             onClick.append(';');
         }
 
-        //call the clear_<formName> method
-        onClick.append(HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName)).append("();");
+        if (RendererUtils.isAdfOrTrinidadForm(formInfo.getForm())) {
+            onClick.append("submitForm('");
+            onClick.append(formInfo.getForm().getClientId(facesContext));
+            onClick.append("',1,{source:'");
+            onClick.append(component.getClientId(facesContext));
+            onClick.append("'});return false;");
+        }
+        else {
+            HtmlRendererUtils.renderFormSubmitScript(facesContext);
+
+            StringBuffer params = addChildParameters(component, nestingForm);
+
+            String target = getTarget(component);
+
+            onClick.append("return ").
+                append(HtmlRendererUtils.SUBMIT_FORM_FN_NAME).append("('").
+                append(formName).append("','").
+                append(clientId).append("'");
+
+            if (params.length() > 2 || target != null) {
+                onClick.append(",").
+                    append(target == null ? "null" : ("'" + target + "'")).append(",").
+                    append(params);
+            }
+            onClick.append(");");
+
 
-        String jsForm = "document.forms['" + formName + "']";
+            //render hidden field - todo: in here for backwards compatibility
+            String hiddenFieldName = HtmlRendererUtils.getHiddenCommandLinkFieldName(formInfo);
+            addHiddenCommandParameter(facesContext, nestingForm, hiddenFieldName);
 
-        if (MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isAutoScroll())
-        {
-            org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils.appendAutoScrollAssignment(onClick, formName);
+            //render hidden field - todo: in here for backwards compatibility
+            String hiddenFieldNameMyFacesOld = HtmlRendererUtils.getHiddenCommandLinkFieldNameMyfacesOld(formInfo);
+            addHiddenCommandParameter(facesContext, nestingForm, hiddenFieldNameMyFacesOld);
         }
 
-        //add id parameter for decode
-        String hiddenFieldName = HtmlRendererUtils.getHiddenCommandLinkFieldName(formName);
-        onClick.append(jsForm);
-        onClick.append(".elements['").append(hiddenFieldName).append("']");
-        onClick.append(".value='").append(clientId).append("';");
-        addHiddenCommandParameter(facesContext, nestingForm, hiddenFieldName);
+        writer.startElement(HTML.ANCHOR_ELEM, component);
+        writer.writeURIAttribute(HTML.HREF_ATTR, "#", null);
+        writer.writeAttribute(HTML.ONCLICK_ATTR, onClick.toString(), null);
+    }
+
+    private String getTarget(UIComponent component) {
+        // for performance reason: double check for the target attribute
+        String target;
+        if (component instanceof HtmlCommandLink) {
+            target = ((HtmlCommandLink) component).getTarget();
+        }
+        else {
+            target = (String) component.getAttributes().get(HTML.TARGET_ATTR);
+        }
+        return target;
+    }
 
+    private StringBuffer addChildParameters(UIComponent component, UIComponent nestingForm) {
         //add child parameters
-        for (Iterator it = getChildren(component).iterator(); it.hasNext(); )
-        {
-            UIComponent child = (UIComponent)it.next();
-            if (child instanceof UIParameter)
-            {
-                String name = ((UIParameter)child).getName();
-                Object value = ((UIParameter)child).getValue();
+        StringBuffer params = new StringBuffer();
+        params.append("[");
+        for (Iterator it = getChildren(component).iterator(); it.hasNext();) {
 
-                renderLinkParameter(name, value, onClick, jsForm, nestingForm);
-            }
-        }
+            UIComponent child = (UIComponent) it.next();
+            if (child instanceof UIParameter) {
+                String name = ((UIParameter) child).getName();
 
-        // target
-        // todo: can we eliminate the if and rely on the second call only ?
-        // see MYFACES-310, specifically the comment by Emond Papegaaij. Will try
-        // after testing framework is in place & tests are written.
-        String target = null;
-        if (component instanceof HtmlCommandLink)
-        {
-            target = ((HtmlCommandLink)component).getTarget();
-        }
-        else
-        {
-            target = (String)component.getAttributes().get(HTML.TARGET_ATTR);
-        }
-        if (target != null && target.trim().length() > 0) {
-            onClick.append(jsForm);
-            onClick.append(".target='");
-            onClick.append(target);
-            onClick.append("';");
-        }
+                if (name == null) {
+                    throw new IllegalArgumentException("Unnamed parameter value not allowed within command link.");
+                }
 
-        // onSubmit
-        onClick.append("if(").append(jsForm).append(".onsubmit){var result=").append(jsForm).append(".onsubmit();  if( (typeof result == 'undefined') || result ) {"+jsForm+".submit();}}else{");
+                addHiddenCommandParameter(FacesContext.getCurrentInstance(), nestingForm, name);
 
-        //submit
-        onClick.append(jsForm);
-        onClick.append(".submit();}return false;");  //return false, so that browser does not handle the click
+                Object value = ((UIParameter) child).getValue();
 
-        writer.startElement(HTML.ANCHOR_ELEM, component);
-        writer.writeURIAttribute(HTML.HREF_ATTR, "#", null);
-        writer.writeAttribute(HTML.ONCLICK_ATTR, onClick.toString(), null);
+                //UIParameter is no ValueHolder, so no conversion possible - calling .toString on value....
+                String strParamValue = value != null ? org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder.encode(value.toString(), false, false) : "";
+
+
+                if (params.length() > 1) {
+                    params.append(",");
+                }
+
+                params.append("['");
+                params.append(name);
+                params.append("','");
+                params.append(strParamValue);
+                params.append("']");
+            }
+        }
+        params.append("]");
+        return params;
     }
 
     /**
@@ -313,7 +346,7 @@
 	{
 		if (nestingForm != null)
         {
-            HtmlFormRendererBase.addHiddenCommandParameter(nestingForm, hiddenFieldName);
+            HtmlFormRendererBase.addHiddenCommandParameter(facesContext, nestingForm, hiddenFieldName);
         }
 	}
 
@@ -340,7 +373,7 @@
         {
             hrefBuf.append('&');
         }
-        String hiddenFieldName = HtmlRendererUtils.getHiddenCommandLinkFieldName(findNestingForm(component, facesContext).getFormName());
+        String hiddenFieldName = HtmlRendererUtils.getHiddenCommandLinkFieldName(findNestingForm(component, facesContext));
         hrefBuf.append(hiddenFieldName);
         hrefBuf.append('=');
         hrefBuf.append(clientId);

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java Tue Jun  5 14:51:27 2007
@@ -202,6 +202,18 @@
         }
     }
 
+    @Deprecated
+    protected void renderRadio(FacesContext facesContext,
+                               UIComponent uiComponent,
+                               String value,
+                               String label,
+                               boolean disabled,
+                               boolean checked, boolean renderId)
+            throws IOException
+    {
+        renderRadio(facesContext, (UIInput) uiComponent, value, disabled, checked, renderId, 0);
+    }
+
     /**
      * Renders the input item
      * @return the 'id' value of the rendered element

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRenderer.java Tue Jun  5 14:51:27 2007
@@ -15,10 +15,14 @@
  */
 package org.apache.myfaces.shared.renderkit.html;
 
+import org.apache.myfaces.shared.renderkit.JSFAttr;
+
 import javax.faces.application.ViewHandler;
 import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.faces.render.Renderer;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -69,4 +73,77 @@
         return viewHandler.getActionURL(facesContext, viewId);
     }
 
+    /**
+     * Renders the client ID as an "id".
+     */
+    protected void renderId(
+      FacesContext context,
+      UIComponent  component) throws IOException
+    {
+      if (shouldRenderId(context, component))
+      {
+        String clientId = getClientId(context, component);
+        context.getResponseWriter().writeAttribute(HTML.ID_ATTR, clientId, JSFAttr.ID_ATTR);
+      }
+    }
+
+    /**
+     * Returns the client ID that should be used for rendering (if
+     * {@link #shouldRenderId} returns true).
+     */
+    protected String getClientId(
+      FacesContext context,
+      UIComponent  component)
+    {
+      return component.getClientId(context);
+    }
+
+    /**
+     * Returns true if the component should render an ID.  Components
+     * that deliver events should always return "true".
+     * @todo Is this a bottleneck?  If so, optimize!
+     */
+    protected boolean shouldRenderId(
+      FacesContext context,
+      UIComponent  component)
+    {
+      String id = component.getId();
+
+      // Otherwise, if ID isn't set, don't bother
+      if (id == null)
+        return false;
+
+      // ... or if the ID was generated, don't bother
+      if (id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
+        return false;
+
+      return true;
+    }
+
+    /**
+     * Coerces an object into a URI, accounting for JSF rules
+     * with initial slashes.
+     */
+    static public String toUri(Object o)
+    {
+      if (o == null)
+        return null;
+
+      String uri = o.toString();
+      if (uri.startsWith("/"))
+      {
+        // Treat two slashes as server-relative
+        if (uri.startsWith("//"))
+        {
+          uri = uri.substring(1);
+        }
+        else
+        {
+          FacesContext fContext = FacesContext.getCurrentInstance();
+          uri = fContext.getExternalContext().getRequestContextPath() + uri;
+        }
+      }
+
+      return uri;
+    }
 }

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java Tue Jun  5 14:51:27 2007
@@ -19,8 +19,10 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.shared.component.DisplayValueOnlyCapable;
 import org.apache.myfaces.shared.component.EscapeCapable;
+import org.apache.myfaces.shared.config.MyfacesConfig;
 import org.apache.myfaces.shared.renderkit.JSFAttr;
 import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
 import org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder;
 import org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils;
 
@@ -28,6 +30,7 @@
 import javax.faces.component.*;
 import javax.faces.component.html.HtmlDataTable;
 import javax.faces.component.html.HtmlPanelGrid;
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import javax.faces.convert.Converter;
@@ -46,8 +49,32 @@
     //private static final String[] EMPTY_STRING_ARRAY = new String[0];
     private static final String LINE_SEPARATOR = System.getProperty(
             "line.separator", "\r\n");
+    private static final char TABULATOR = '\t';
+
+    public static final String HIDDEN_COMMANDLINK_FIELD_NAME = "_idcl";
+    public static final String HIDDEN_COMMANDLINK_FIELD_NAME_MYFACES_OLD = "_link_hidden_";
+    public static final String HIDDEN_COMMANDLINK_FIELD_NAME_TRINIDAD = "source";
+
+    public static final String CLEAR_HIDDEN_FIELD_FN_NAME =
+        "clearFormHiddenParams";
+    public static final String SUBMIT_FORM_FN_NAME = "oamSubmitForm";
+    public static final String ALLOW_CDATA_SECTION_ON = "org.apache.myfaces.ResponseWriter.CdataSectionOn";
+
+    private static final String SET_HIDDEN_INPUT_FN_NAME = "oamSetHiddenInput";
+    private static final String CLEAR_HIDDEN_INPUT_FN_NAME = "oamClearHiddenInput";
+
+    private static final String AUTO_SCROLL_PARAM = "autoScroll";
+    private static final String AUTO_SCROLL_FUNCTION = "getScrolling";
+
+    private static final String FIRST_SUBMIT_SCRIPT_ON_PAGE = "org.apache.MyFaces.FIRST_SUBMIT_SCRIPT_ON_PAGE";
+
+	public static final String NON_SUBMITTED_VALUE_WARNING
+	= "There should always be a submitted value for an input if it is rendered,"
+	+ " its form is submitted, and it was not originally rendered disabled or read-only."
+	+ "  You cannot submit a form after disabling an input element via javascript."
+	+ "  Consider setting read-only to true instead"
+    + " or resetting the disabled value back to false prior to form submission.";
 
-    public static final String HIDDEN_COMMANDLINK_FIELD_NAME = "_link_hidden_";
 
     private HtmlRendererUtils() {
         // utility class, do not instantiate
@@ -80,13 +107,10 @@
             ((EditableValueHolder) component).setSubmittedValue(paramMap
                     .get(clientId));
         }
-        else
-        {
-            log.warn(
-                "There should always be a submitted value for an input if it"
-                + " is rendered, its form is submitted, and it is not disabled"
-                + " or read-only. Component : "+
-                RendererUtils.getPathToComponent(component));
+        else {
+            log.warn(NON_SUBMITTED_VALUE_WARNING +
+                " Component : " +
+                    RendererUtils.getPathToComponent(component));
         }
     }
 
@@ -130,8 +154,8 @@
     public static boolean isDisabledOrReadOnly(UIComponent component)
     {
         return isDisplayValueOnly(component) ||
-               isDisabled(component) ||
-               isReadOnly(component);
+            isDisabled(component) ||
+            isReadOnly(component);
     }
 
     public static boolean isDisabled(UIComponent component)
@@ -412,7 +436,7 @@
                 String itemStrValue = org.apache.myfaces.shared.renderkit.RendererUtils.getConvertedStringValue(context, component,
                                                                             converter, selectItem);
 
-                writer.write("\t");
+                writer.write(TABULATOR);
                 writer.startElement(HTML.OPTION_ELEM, component);
                 if (itemStrValue != null) {
                     writer.writeAttribute(HTML.VALUE_ATTR, itemStrValue, null);
@@ -887,6 +911,342 @@
         writer.endElement(HTML.SPAN_ELEM);
     }
 
+    public static void appendClearHiddenCommandFormParamsFunctionCall(StringBuffer buf, String formName) {
+        appendClearHiddenCommandFormParamsFunctionCall(new ScriptContext(buf,false), formName);
+    }
+
+    private static void appendClearHiddenCommandFormParamsFunctionCall(ScriptContext context, String formName) {
+
+        String functionName = HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName);
+
+        if(formName == null)
+        {
+            context.prettyLine();
+            context.append("var clearFn = ");
+            context.append(functionName);
+            context.append(";");
+            context.prettyLine();
+            context.append("if(typeof eval('window.'+clearFn)!='undefined')");
+            context.append("{");
+            context.append("eval('window.'+clearFn+'(formName)');");
+            context.append("}");
+        }
+        else
+        {
+            context.prettyLine();
+            context.append("if(typeof window.");
+            context.append(functionName);
+            context.append("!='undefined')");
+            context.append("{");
+            context.append(functionName).append("('").append(formName).append("');");
+            context.append("}");
+        }
+    }
+
+
+    public static void renderFormSubmitScript(FacesContext facesContext)
+            throws IOException
+    {
+
+        Map map = facesContext.getExternalContext().getRequestMap();
+        Boolean firstScript = (Boolean) map.get(FIRST_SUBMIT_SCRIPT_ON_PAGE);
+
+        if (firstScript == null || firstScript.equals(Boolean.TRUE)) {
+            map.put(FIRST_SUBMIT_SCRIPT_ON_PAGE, Boolean.FALSE);
+            HtmlRendererUtils.renderFormSubmitScriptIfNecessary(facesContext);
+
+        }
+    }
+
+    private static void renderFormSubmitScriptIfNecessary(FacesContext facesContext) throws IOException {
+        ResponseWriter writer = facesContext.getResponseWriter();
+
+        writer.startElement(HTML.SCRIPT_ELEM, null);
+        writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+
+        final ExternalContext externalContext = facesContext.getExternalContext();
+		final MyfacesConfig currentInstance = MyfacesConfig.getCurrentInstance(externalContext);
+		boolean autoScroll = currentInstance.isAutoScroll();
+
+        ScriptContext context = new ScriptContext(currentInstance
+            .isPrettyHtml());
+        context.prettyLine();
+        context.increaseIndent();
+
+        prepareScript(context, autoScroll);
+
+        writer.writeText(context.toString(),null);
+
+        writer.endElement(HTML.SCRIPT_ELEM);
+    }
+
+    private static void prepareScript(ScriptContext context, boolean autoScroll)
+    {
+
+        context.prettyLine();
+
+        //render a function to create a hidden input, if it doesn't exist
+        context.append("function ");
+        context.append(SET_HIDDEN_INPUT_FN_NAME).append("(formname, name, value)");
+        context.append("{");
+        context.append("var form = document.forms[formname];");
+        context.prettyLine();
+        context.append("if(typeof form.elements[name]=='undefined')");
+        context.append("{");
+        context.append("var newInput = document.createElement('input');");
+        context.prettyLine();
+        context.append("newInput.setAttribute('type','hidden');");
+        context.prettyLine();
+        context.append("newInput.setAttribute('name',name);");
+        context.prettyLine();
+        context.append("newInput.setAttribute('value',value);");
+        context.prettyLine();
+        context.append("form.appendChild(newInput);");
+        context.append("}");
+        context.append("else");
+        context.append("{");
+        context.append("form.elements[name].value=value;");
+        context.append("}");
+
+        context.append("}");
+
+        context.prettyLine();
+
+        context.prettyLine();
+
+        //render a function to clear a hidden input, if it exists
+        context.append("function ");
+        context.append(CLEAR_HIDDEN_INPUT_FN_NAME).append("(formname, name, value)");
+        context.append("{");
+        context.append("var form = document.forms[formname];");
+        context.prettyLine();
+        context.append("if(typeof form.elements[name]!='undefined')");
+        context.append("{");
+        context.append("form.elements[name].value=null;");
+        context.append("}");
+
+        context.append("}");
+
+        context.prettyLine();
+
+        context.append("function ");
+        context.append(SUBMIT_FORM_FN_NAME).append("(formName, linkId, target, params)");
+        context.append("{");
+
+        //call the script to clear the form (clearFormHiddenParams_<formName>) method - optionally, only necessary for IE5.5.
+        //todo: if IE5.5. is ever desupported, we can get rid of this and instead rely on the last part of this script to
+        //clear the parameters
+        HtmlRendererUtils.appendClearHiddenCommandFormParamsFunctionCall(context, null);
+
+        if (autoScroll)
+        {
+            appendAutoScrollAssignment(context, null);
+        }
+
+        context.prettyLine();
+
+        //set the target (and save it)
+        context.append("var oldTarget = '';");
+        context.prettyLine();
+        context.append("if((typeof target!='undefined') && target != null)");
+        context.append("{");
+        context.append("oldTarget=document.forms[formName].target;");
+        context.prettyLine();
+        context.append("document.forms[formName].target=target;");
+        context.append("}");
+
+        //set the submit parameters
+
+        context.append("if((typeof params!='undefined') && params != null)");
+        context.append("{");
+        context.append("for(var i=0; i<params.length; i++)");
+        context.append("{");
+        context.append(SET_HIDDEN_INPUT_FN_NAME).append("(formName,params[i][0], params[i][1]);");
+        context.append("}");
+        context.append("}");
+
+        context.prettyLine();
+
+        context.append(SET_HIDDEN_INPUT_FN_NAME);
+        context.append("(formName,formName +'"+NamingContainer.SEPARATOR_CHAR+
+                "'+'"+HtmlRendererUtils.HIDDEN_COMMANDLINK_FIELD_NAME+"',linkId);");
+
+        context.prettyLine();
+        context.prettyLine();
+
+        //do the actual submit calls
+
+        context.append("if(document.forms[formName].onsubmit)");
+        context.append("{");
+        context.append("var result=document.forms[formName].onsubmit();");
+        context.prettyLine();
+        context.append("if((typeof result=='undefined')||result)");
+        context.append("{");
+        context.append("document.forms[formName].submit();");
+        context.append("}");
+        context.append("}");
+        context.append("else ");
+        context.append("{");
+        context.append("document.forms[formName].submit();");
+        context.append("}");
+
+        //reset the target
+        context.append("if(oldTarget==null) oldTarget='';");
+        context.prettyLine();
+        context.append("document.forms[formName].target=oldTarget;");
+        context.prettyLine();
+
+        //clear the individual parameters - to make sure that even if the clear-function isn't called,
+        // the back button/resubmit functionality will still work in all browsers except IE 5.5.
+
+        context.append("if((typeof params!='undefined') && params != null)");
+        context.append("{");
+        context.append("for(var i=0; i<params.length; i++)");
+        context.append("{");
+        context.append(CLEAR_HIDDEN_INPUT_FN_NAME).append("(formName,params[i][0], params[i][1]);");
+        context.append("}");
+        context.append("}");
+
+        context.prettyLine();
+
+        context.append(CLEAR_HIDDEN_INPUT_FN_NAME);
+        context.append("(formName,formName +'"+NamingContainer.SEPARATOR_CHAR+
+                "'+'"+HtmlRendererUtils.HIDDEN_COMMANDLINK_FIELD_NAME+"',linkId);");
+
+
+        //return false, so that browser does not handle the click
+        context.append("return false;");
+        context.append("}");
+
+        context.prettyLineDecreaseIndent();
+    }
+
+    /**
+     * Adds the hidden form input value assignment that is necessary for the autoscroll
+     * feature to an html link or button onclick attribute.
+     */
+    public static void appendAutoScrollAssignment(StringBuffer onClickValue, String formName)
+    {
+        appendAutoScrollAssignment(new ScriptContext(onClickValue,false),formName);
+    }
+
+    private static void appendAutoScrollAssignment(ScriptContext scriptContext, String formName)
+    {
+        String formNameStr = formName == null? "formName" : (new StringBuffer("'").append(formName).append("'").toString());
+        String paramName = new StringBuffer().append("'").
+                append(AUTO_SCROLL_PARAM).append("'").toString();
+        String value = new StringBuffer().append(AUTO_SCROLL_FUNCTION).append("()").toString();
+
+        scriptContext.prettyLine();
+        scriptContext.append("if(typeof window."+AUTO_SCROLL_FUNCTION+"!='undefined')");
+        scriptContext.append("{");
+        scriptContext.append(SET_HIDDEN_INPUT_FN_NAME);
+        scriptContext.append("(").append(formNameStr).append(",").append(paramName).append(",").append(value).append(");");
+        scriptContext.append("}");
+
+    }
+
+    /**
+     * Renders the hidden form input that is necessary for the autoscroll feature.
+     */
+    public static void renderAutoScrollHiddenInput(FacesContext facesContext, ResponseWriter writer) throws IOException
+    {
+        writePrettyLineSeparator(facesContext);
+        writer.startElement(HTML.INPUT_ELEM, null);
+        writer.writeAttribute(HTML.TYPE_ATTR, "hidden", null);
+        writer.writeAttribute(HTML.NAME_ATTR, AUTO_SCROLL_PARAM, null);
+        writer.endElement(HTML.INPUT_ELEM);
+        writePrettyLineSeparator(facesContext);
+    }
+
+    /**
+     * Renders the autoscroll javascript function.
+     */
+    public static void renderAutoScrollFunction(FacesContext facesContext,
+                                                ResponseWriter writer) throws IOException
+    {
+        writePrettyLineSeparator(facesContext);
+        writer.startElement(HTML.SCRIPT_ELEM,null);
+        writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,null);
+
+        ScriptContext script = new ScriptContext(
+                MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isPrettyHtml());
+
+        script.prettyLineIncreaseIndent();
+
+        script.append("function ");
+        script.append(AUTO_SCROLL_FUNCTION);
+        script.append("()");
+        script.append("{");
+        script.append("var x = 0; var y = 0;");
+        script.append( "if (self.pageXOffset || self.pageYOffset)");
+        script.append("{");
+        script.append("x = self.pageXOffset;");
+        script.prettyLine();
+        script.append("y = self.pageYOffset;");
+        script.append("}");
+        script.append(" else if ((document.documentElement && document.documentElement.scrollLeft)||(document.documentElement && document.documentElement.scrollTop))");
+        script.append("{");
+        script.append("x = document.documentElement.scrollLeft;");
+        script.prettyLine();
+        script.append("y = document.documentElement.scrollTop;");
+        script.append("}");
+        script.append(" else if (document.body) ");
+        script.append("{");
+        script.append("x = document.body.scrollLeft;");
+        script.prettyLine();
+        script.append("y = document.body.scrollTop;");
+        script.append("}");
+        script.append("return x + \",\" + y;");
+        script.append("}");
+
+        ExternalContext externalContext = facesContext.getExternalContext();
+        String oldViewId = JavascriptUtils.getOldViewId(externalContext);
+        if (oldViewId != null && oldViewId.equals(facesContext.getViewRoot().getViewId()))
+        {
+            //ok, we stayed on the same page, so let's scroll it to the former place
+            String scrolling = (String)externalContext.getRequestParameterMap().get(AUTO_SCROLL_PARAM);
+            if (scrolling != null && scrolling.length() > 0)
+            {
+                String x = "0";
+                String y = "0";
+                int comma = scrolling.indexOf(',');
+                if (comma == -1)
+                {
+                    log.warn("Illegal autoscroll request parameter: " + scrolling);
+                }
+                else
+                {
+                    x = scrolling.substring(0, comma);
+                    if (x.equals("undefined")) x = "0";
+                    y = scrolling.substring(comma + 1);
+                    if (y.equals("undefined")) y = "0";
+                }
+                script.append("window.scrollTo(").append(x).append(",").append(y).append(");\n");
+            }
+        }
+
+        writer.writeText(script.toString(),null);
+
+        writer.endElement(HTML.SCRIPT_ELEM);
+        writePrettyLineSeparator(facesContext);
+    }
+
+    public static boolean isAllowedCdataSection(FacesContext fc) {
+		Boolean value = null;
+
+		if (fc != null) {
+			value = (Boolean) fc.getExternalContext().getRequestMap().get(ALLOW_CDATA_SECTION_ON);
+		}
+
+        return value != null && ((Boolean) value).booleanValue();
+    }
+
+    public static void allowCdataSection(FacesContext fc, boolean cdataSectionAllowed)
+    {
+          fc.getExternalContext().getRequestMap().put(ALLOW_CDATA_SECTION_ON,Boolean.valueOf(cdataSectionAllowed));
+    }
+
     public static class LinkParameter {
         private String _name;
 
@@ -1039,61 +1399,60 @@
      * @return String
      */
     public static String getClearHiddenCommandFormParamsFunctionName(
-            String formName) {
-        return "clear_"
-               + JavascriptUtils.getValidJavascriptName(formName, false);
+            String formName)
+    {
+        if (formName == null)
+        {
+            return "'" + CLEAR_HIDDEN_FIELD_FN_NAME
+                    + "_'+formName.replace(/-/g, '\\$" + NamingContainer.SEPARATOR_CHAR + "').replace(/" + NamingContainer.SEPARATOR_CHAR + "/g,'_')";
+        }
+
+        return JavascriptUtils.getValidJavascriptNameAsInRI(CLEAR_HIDDEN_FIELD_FN_NAME
+                + "_"
+                + formName
+                .replace(NamingContainer.SEPARATOR_CHAR, '_'));
     }
 
-    /**
-     * Return the clientId of the form associated with the specified component.
-     * <p>
-     * If the component is nested within a UIForm, that component's id is returned.
-     * <p>
-     * Otherwise the component of the "dummy form" is returned. At most one dummy
-     * form is output into each page; all components which can cause page submission
-     * but are not nested within a real form will cause the dummy form to be
-     * submitted instead.
-     */
-    /*
-    public static String getFormName(UIComponent component, FacesContext context) {
-        //Find form
-        UIComponent parent = component.getParent();
-        while (parent != null && !(parent instanceof UIForm)) {
-            parent = parent.getParent();
-        }
-
-        if (parent != null) {
-            //link is nested inside a form
-            return ((UIForm) parent).getClientId(context);
-        }
-        //not nested in form, we must add a dummy form at the end of the
-        // document
-        return org.apache.myfaces.shared.renderkit.html.util.DummyFormUtils.DUMMY_FORM_NAME;
+    public static String getClearHiddenCommandFormParamsFunctionNameMyfacesLegacy(
+            String formName)
+    {
+        return "clear_"
+                + JavascriptUtils.getValidJavascriptName(formName, false);
     }
-    */
+
 
     /**
      * Get the name of the request parameter that holds the id of the
      * link-type component that caused the form to be submitted.
-     * <p>
+     * <p/>
      * Within each page there may be multiple "link" type components that
      * cause page submission. On the server it is necessary to know which
      * of these actually caused the submit, in order to invoke the correct
      * listeners. Such components therefore store their id into the
-     * "hidden command link field" in their associated form before 
-     * submitting it. 
-     * <p>
+     * "hidden command link field" in their associated form before
+     * submitting it.
+     * <p/>
      * The field is always a direct child of each form, and has the same
      * <i>name</i> in each form. The id of the form component is therefore
      * both necessary and sufficient to determine the full name of the
      * field.
      */
-    public static String getHiddenCommandLinkFieldName(String formName) {
-        return formName + NamingContainer.SEPARATOR_CHAR
-               + HIDDEN_COMMANDLINK_FIELD_NAME;
+    public static String getHiddenCommandLinkFieldName(FormInfo formInfo) {
+        if (RendererUtils.isAdfOrTrinidadForm(formInfo.getForm())) {
+            return HIDDEN_COMMANDLINK_FIELD_NAME_TRINIDAD;
+        }
+        return formInfo.getFormName() + NamingContainer.SEPARATOR_CHAR
+            + HIDDEN_COMMANDLINK_FIELD_NAME;
+    }
+
+    public static String getHiddenCommandLinkFieldNameMyfacesOld(FormInfo formInfo) {
+        return formInfo.getFormName() + NamingContainer.SEPARATOR_CHAR
+            + HIDDEN_COMMANDLINK_FIELD_NAME_MYFACES_OLD;
     }
 
+
     private static String HTML_CONTENT_TYPE = "text/html";
+    private static String TEXT_ANY_CONTENT_TYPE = "text/*";
     private static String ANY_CONTENT_TYPE = "*/*";
 
     public static String DEFAULT_CHAR_ENCODING = "ISO-8859-1";
@@ -1171,7 +1530,8 @@
     private static boolean isHTMLContentType(String contentType)
     {
         return contentType.indexOf(HTML_CONTENT_TYPE) != -1 ||
-               contentType.indexOf(ANY_CONTENT_TYPE) != -1;
+            contentType.indexOf(ANY_CONTENT_TYPE) != -1 ||
+            contentType.indexOf(TEXT_ANY_CONTENT_TYPE) != -1 ;
     }
 
     public static boolean isXHTMLContentType(String contentType)
@@ -1225,5 +1585,132 @@
             return null;
 
         return (String)component.getAttributes().get(JSFAttr.STYLE_LOCATION);
+    }
+
+    /**
+     * The ScriptContext offers methods and fields
+     * to help with rendering out a script and keeping a
+     * proper formatting.
+     */
+    public static class ScriptContext
+    {
+        private long currentIndentationLevel;
+        private StringBuffer buffer = new StringBuffer();
+        private boolean prettyPrint = false;
+        /**
+         *  automatic formatting will render
+         *  new-lines and indents if blocks are opened
+         *  and closed - attention: you need to append
+         *  opening and closing brackets of blocks separately in this case!
+         */
+        private boolean automaticFormatting = true;
+
+        public ScriptContext()
+        {
+
+        }
+
+        public ScriptContext(boolean prettyPrint)
+        {
+            this.prettyPrint = prettyPrint;
+        }
+
+        public ScriptContext(StringBuffer buf, boolean prettyPrint)
+        {
+            this.prettyPrint = prettyPrint;
+            this.buffer = buf;
+        }
+
+        public void increaseIndent()
+        {
+            currentIndentationLevel++;
+        }
+
+        public void decreaseIndent()
+        {
+            currentIndentationLevel--;
+
+            if(currentIndentationLevel<0)
+                currentIndentationLevel=0;
+        }
+
+        public void prettyLine()
+        {
+            if(prettyPrint)
+            {
+                append(LINE_SEPARATOR);
+
+                for(int i=0; i<getCurrentIndentationLevel(); i++)
+                    append(TABULATOR);
+            }
+        }
+
+        public void prettyLineIncreaseIndent()
+        {
+            increaseIndent();
+            prettyLine();
+        }
+
+        public void prettyLineDecreaseIndent()
+        {
+            decreaseIndent();
+            prettyLine();
+        }
+
+        public long getCurrentIndentationLevel()
+        {
+            return currentIndentationLevel;
+        }
+
+        public void setCurrentIndentationLevel(long currentIndentationLevel)
+        {
+            this.currentIndentationLevel = currentIndentationLevel;
+        }
+
+        public ScriptContext append(String str)
+        {
+
+            if(automaticFormatting && str.length()==1)
+            {
+                boolean openBlock = str.equals("{");
+                boolean closeBlock = str.equals("}");
+
+                if(openBlock)
+                {
+                    prettyLine();
+                }
+                else if(closeBlock)
+                {
+                    prettyLineDecreaseIndent();
+                }
+
+                buffer.append(str);
+
+                if(openBlock)
+                {
+                    prettyLineIncreaseIndent();
+                }
+                else if(closeBlock)
+                {
+                    prettyLine();
+                }
+            }
+            else
+            {
+                buffer.append(str);
+            }
+            return this;
+        }
+
+        public ScriptContext append(char c)
+        {
+            buffer.append(c);
+            return this;
+        }
+
+        public String toString()
+        {
+            return buffer.toString();
+        }
     }
 }

Modified: myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
URL: http://svn.apache.org/viewvc/myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java?view=diff&rev=544646&r1=544645&r2=544646
==============================================================================
--- myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java (original)
+++ myfaces/shared/branches/3_0_0/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java Tue Jun  5 14:51:27 2007
@@ -22,6 +22,7 @@
 
 import javax.faces.FacesException;
 import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -58,6 +59,13 @@
 
     private static final Set s_emptyHtmlElements = new HashSet();
 
+    private static final String CDATA_START = "<![CDATA[ \n";
+    private static final String COMMENT_START = "<!--\n";
+    private static final String CDATA_COMMENT_END = "\n//]]>";
+    private static final String CDATA_END = "\n]]>";
+    private static final String COMMENT_COMMENT_END = "\n//-->";
+    private static final String COMMENT_END = "\n-->";
+
     static
     {
         s_emptyHtmlElements.add("area");
@@ -186,11 +194,14 @@
                 {
                     if(HtmlRendererUtils.isXHTMLContentType(_contentType))
                     {
-                        _writer.write("<![CDATA[ \n");
+                        if(HtmlRendererUtils.isAllowedCdataSection(FacesContext.getCurrentInstance()))
+                        {
+                            _writer.write(CDATA_START);
+                        }
                     }
                     else
                     {
-                        _writer.write("<!--\n");
+                        _writer.write(COMMENT_START);
                     }
                 }
             }
@@ -267,17 +278,20 @@
         {
             if(HtmlRendererUtils.isXHTMLContentType(_contentType))
             {
-                if(isScript())
-                    _writer.write("\n//]]>");
-                else
-                    _writer.write("\n]]>");
+                if(HtmlRendererUtils.isAllowedCdataSection(FacesContext.getCurrentInstance()))
+                {
+                    if(isScript())
+                        _writer.write(CDATA_COMMENT_END);
+                    else
+                        _writer.write(CDATA_END);
+                }
             }
             else
             {
                 if(isScript())
-                    _writer.write("\n//-->");
+                    _writer.write(COMMENT_COMMENT_END);
                 else
-                    _writer.write("\n-->");
+                    _writer.write(COMMENT_END);
             }
         }
 



Mime
View raw message