myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r328404 [2/3] - in /myfaces: examples/trunk/simple/css/jscookmenu/ examples/trunk/simple/css/jscookmenu/ThemeOffice/ sandbox/trunk/src/java/org/apache/myfaces/custom/accordion/ sandbox/trunk/src/java/org/apache/myfaces/custom/autoupdatedata...
Date Tue, 25 Oct 2005 16:22:13 GMT
Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsFilter.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsFilter.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsFilter.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsFilter.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2004 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 org.apache.myfaces.component.html.util;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.fileupload.FileUpload;
+
+/**
+ * This filters is mandatory for the use of many components.
+ * It handles the Multipart requests (for file upload)
+ * It's used by the components that need javascript libraries
+ * 
+ * @author Sylvain Vieujot (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class ExtensionsFilter implements Filter {
+
+    private int uploadMaxFileSize = 100 * 1024 * 1024; // 10 MB
+
+    private int uploadThresholdSize = 1 * 1024 * 1024; // 1 MB
+
+    private String uploadRepositoryPath = null; //standard temp directory
+    private static final String DOFILTER_CALLED = "org.apache.myfaces.component.html.util.ExtensionFilter.doFilterCalled";
+
+    /**
+     * Init method for this filter
+     */
+    public void init(FilterConfig filterConfig) {
+
+        String param = filterConfig.getInitParameter("uploadMaxFileSize");
+
+        uploadMaxFileSize = resolveSize(param, uploadMaxFileSize);
+
+        param = filterConfig.getInitParameter("uploadThresholdSize");
+
+        uploadThresholdSize = resolveSize(param, uploadThresholdSize);
+
+        uploadRepositoryPath = filterConfig.getInitParameter("uploadRepositoryPath");
+    }
+
+    private int resolveSize(String param, int defaultValue) {
+        int numberParam = defaultValue;
+
+        if (param != null) {
+            param = param.toLowerCase();
+            int factor = 1;
+            String number = param;
+
+            if (param.endsWith("g")) {
+                factor = 1024 * 1024 * 1024;
+                number = param.substring(0, param.length() - 1);
+            } else if (param.endsWith("m")) {
+                factor = 1024 * 1024;
+                number = param.substring(0, param.length() - 1);
+            } else if (param.endsWith("k")) {
+                factor = 1024;
+                number = param.substring(0, param.length() - 1);
+            }
+
+            numberParam = Integer.parseInt(number) * factor;
+        }
+        return numberParam;
+    }
+
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+
+        if(request.getAttribute(DOFILTER_CALLED)!=null)
+        {
+            chain.doFilter(request, response);
+            return;
+        }
+
+        request.setAttribute(DOFILTER_CALLED,"true");
+
+        if (!(response instanceof HttpServletResponse)) {
+            chain.doFilter(request, response);
+            return;
+        }
+
+		HttpServletResponse httpResponse = (HttpServletResponse) response; 
+        HttpServletRequest httpRequest = (HttpServletRequest) request;
+
+        // Serve resources
+        AddResource addResource = AddResource.getInstance(httpRequest);
+        if( addResource.isResourceUri( httpRequest ) ){
+            addResource.serveResource(httpRequest, httpResponse);
+            return;
+        }
+        
+        HttpServletRequest extendedRequest = httpRequest;
+        
+        // For multipart/form-data requests
+        if (FileUpload.isMultipartContent(httpRequest)) {
+            extendedRequest = new MultipartRequestWrapper(httpRequest, uploadMaxFileSize, uploadThresholdSize, uploadRepositoryPath);
+        }
+        
+        ExtensionsResponseWrapper extendedResponse = new ExtensionsResponseWrapper((HttpServletResponse) response);
+        
+        // Standard request
+        chain.doFilter(extendedRequest, extendedResponse);
+        
+        extendedResponse.finishResponse();
+        
+        if( ! addResource.hasHeaderInfos(extendedRequest) ){
+            response.getOutputStream().write( extendedResponse.getBytes());
+            return;
+        }
+        
+        // Some headerInfo has to be added
+        addResource.writeWithFullHeader(extendedRequest, extendedResponse, (HttpServletResponse)response);
+    }
+    
+    /**
+     * Destroy method for this filter
+     */
+    public void destroy() {
+		// NoOp
+    }
+}

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsFilter.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsResponseWrapper.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsResponseWrapper.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsResponseWrapper.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsResponseWrapper.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2004 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 org.apache.myfaces.component.html.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import org.xml.sax.InputSource;
+
+/**
+ * @author Sylvain Vieujot (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class ExtensionsResponseWrapper extends HttpServletResponseWrapper {
+    private ByteArrayOutputStream stream = null;
+    private PrintWriter printWriter = null;
+
+    public ExtensionsResponseWrapper(HttpServletResponse response){
+        super( response );
+
+        stream = new ByteArrayOutputStream();
+    }
+
+
+    public byte[] getBytes() {
+        return stream.toByteArray();
+    }
+
+    public String toString(){
+    	try{
+            return stream.toString(getCharacterEncoding());
+    	}catch(UnsupportedEncodingException e){
+    		// an attempt to set an invalid character encoding would have caused this exception before
+            throw new RuntimeException("Response accepted invalid character encoding " + getCharacterEncoding());
+    	}
+    }
+
+    /** This method is used by Tomcat.
+     */
+    public PrintWriter getWriter(){
+        if( printWriter == null ){
+			OutputStreamWriter streamWriter = new OutputStreamWriter(stream, Charset.forName(getCharacterEncoding()));
+			printWriter = new PrintWriter(streamWriter, true);
+			//printWriter = new PrintWriter(stream, true); // autoFlush is true
+        }
+        return printWriter;
+    }
+
+	/** This method is used by Jetty.
+	*/
+	public ServletOutputStream getOutputStream(){
+		return new MyServletOutputStream( stream );
+	}
+
+    public InputSource getInputSource(){
+		ByteArrayInputStream bais = new ByteArrayInputStream( stream.toByteArray() );
+		return new InputSource( bais );
+    }
+
+     /**
+     *  Prevent content-length being set as the page might be modified.
+     */
+    public void setContentLength(int contentLength) {
+        // noop
+    }
+
+    public void flushBuffer() throws IOException{
+    	stream.flush();
+    }
+
+    public void finishResponse() {
+        try {
+            if (printWriter != null) {
+				printWriter.close();
+            } else {
+                if (stream != null) {
+                    stream.close();
+                }
+            }
+        } catch (IOException e) {
+			e.printStackTrace();
+        }
+    }
+
+    /** Used in the <code>getOutputStream()</code> method.
+     */
+    private class MyServletOutputStream extends ServletOutputStream {
+		private ByteArrayOutputStream outputStream;
+
+		public MyServletOutputStream(ByteArrayOutputStream outputStream){
+			this.outputStream = outputStream;
+		}
+
+		public void write(int b){
+		    outputStream.write( b );
+		}
+
+		public void write(byte[] bytes) throws IOException{
+		    outputStream.write( bytes );
+		}
+
+		public void write(byte[] bytes, int off, int len){
+		    outputStream.write(bytes, off, len);
+		}
+    }
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsResponseWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ExtensionsResponseWrapper.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartFilter.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartFilter.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartFilter.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartFilter.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2005 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 org.apache.myfaces.component.html.util;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.fileupload.FileUpload;
+
+
+/**
+ * This filters is mandatory for the use of many components.
+ * It handles the Multipart requests (for file upload)
+ * It's used by the components that need javascript libraries
+ *
+ * @author Sylvain Vieujot (latest modification by $Author$)
+ * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller </a>
+ * @version $Revision$ $Date$
+ */
+public class MultipartFilter implements Filter
+{
+
+    private int uploadMaxFileSize = 100 * 1024 * 1024; // 10 MB
+
+    private int uploadThresholdSize = 1 * 1024 * 1024; // 1 MB
+
+    private String uploadRepositoryPath = null; //standard temp directory
+
+
+    public void init(FilterConfig filterConfig)
+    {
+        uploadMaxFileSize = resolveSize(filterConfig.getInitParameter("uploadMaxFileSize"), uploadMaxFileSize);
+        uploadThresholdSize = resolveSize(filterConfig.getInitParameter("uploadThresholdSize"), uploadThresholdSize);
+        uploadRepositoryPath = filterConfig.getInitParameter("uploadRepositoryPath");
+    }
+
+
+    private int resolveSize(String param, int defaultValue)
+    {
+        int numberParam = defaultValue;
+
+        if (param != null)
+        {
+            param = param.toLowerCase();
+            int factor = 1;
+            String number = param;
+
+            if (param.endsWith("g"))
+            {
+                factor = 1024 * 1024 * 1024;
+                number = param.substring(0, param.length() - 1);
+            } else if (param.endsWith("m"))
+            {
+                factor = 1024 * 1024;
+                number = param.substring(0, param.length() - 1);
+            } else if (param.endsWith("k"))
+            {
+                factor = 1024;
+                number = param.substring(0, param.length() - 1);
+            }
+
+            numberParam = Integer.parseInt(number) * factor;
+        }
+        return numberParam;
+    }
+
+
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+    {
+        if (!(response instanceof HttpServletResponse))
+        {
+            chain.doFilter(request, response);
+            return;
+        }
+
+        HttpServletRequest httpRequest = (HttpServletRequest) request;
+
+        // For multipart/form-data requests
+        if (FileUpload.isMultipartContent(httpRequest))
+        {
+            chain.doFilter(new MultipartRequestWrapper(httpRequest, uploadMaxFileSize, uploadThresholdSize, uploadRepositoryPath), response);
+        } else
+        {
+            chain.doFilter(request, response);
+        }
+    }
+
+
+    public void destroy()
+    {
+        // NoOp
+    }
+}

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartFilter.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartRequestWrapper.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartRequestWrapper.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartRequestWrapper.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartRequestWrapper.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2004 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 org.apache.myfaces.component.html.util;
+
+import org.apache.commons.fileupload.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import java.io.UnsupportedEncodingException;
+import java.util.*;
+
+/**
+ * @author Sylvain Vieujot (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class MultipartRequestWrapper
+		extends HttpServletRequestWrapper
+{
+    private static Log log = LogFactory.getLog(MultipartRequestWrapper.class);
+
+	HttpServletRequest request = null;
+	HashMap parametersMap = null;
+	DiskFileUpload fileUpload = null;
+	HashMap fileItems = null;
+	int maxSize;
+    int thresholdSize;
+    String repositoryPath;
+
+    public MultipartRequestWrapper(HttpServletRequest request,
+                                   int maxSize, int thresholdSize,
+                                   String repositoryPath){
+		super( request );
+		this.request = request;
+        this.maxSize = maxSize;
+        this.thresholdSize = thresholdSize;
+        this.repositoryPath = repositoryPath;
+	}
+
+	private void parseRequest() {
+		fileUpload = new DiskFileUpload();
+		fileUpload.setFileItemFactory(new DefaultFileItemFactory());
+		fileUpload.setSizeMax(maxSize);
+
+        fileUpload.setSizeThreshold(thresholdSize);
+
+        if(repositoryPath != null && repositoryPath.trim().length()>0)
+            fileUpload.setRepositoryPath(repositoryPath);
+
+	    String charset = request.getCharacterEncoding();
+		fileUpload.setHeaderEncoding(charset);
+
+
+		List requestParameters = null;
+		try{
+			requestParameters = fileUpload.parseRequest(request);
+        } catch (FileUploadBase.SizeLimitExceededException e) {
+
+            // TODO: find a way to notify the user about the fact that the uploaded file exceeded size limit
+
+            if(log.isInfoEnabled())
+                log.info("user tried to upload a file that exceeded file-size limitations.",e);
+
+            requestParameters = Collections.EMPTY_LIST;
+
+		}catch(FileUploadException fue){
+			log.error("Exception while uploading file.", fue);
+			requestParameters = Collections.EMPTY_LIST;
+		}
+
+		parametersMap = new HashMap( requestParameters.size() );
+		fileItems = new HashMap();
+
+    	for (Iterator iter = requestParameters.iterator(); iter.hasNext(); ){
+    		FileItem fileItem = (FileItem) iter.next();
+
+    		if (fileItem.isFormField()) {
+    			String name = fileItem.getFieldName();
+
+    			// The following code avoids commons-fileupload charset problem.
+    			// After fixing commons-fileupload, this code should be
+    			//
+    			// 	String value = fileItem.getString();
+    			//
+    			String value = null;
+    			if ( charset == null) {
+    			    value = fileItem.getString();
+    			} else {
+    			    try {
+    			        value = new String(fileItem.get(), charset);
+    			    } catch (UnsupportedEncodingException e){
+    			        value = fileItem.getString();
+    			    }
+    			}
+
+    			addTextParameter(name, value);
+    		} else { // fileItem is a File
+   				if (fileItem.getName() != null) {
+   					fileItems.put(fileItem.getFieldName(), fileItem);
+   				}
+    		}
+    	}
+
+    	//Add the query string paramters
+        for (Iterator it = request.getParameterMap().entrySet().iterator(); it.hasNext(); )
+        {
+            Map.Entry entry = (Map.Entry)it.next();
+            String[] valuesArray = (String[])entry.getValue();
+            for (int i = 0; i < valuesArray.length; i++)
+            {
+                addTextParameter((String)entry.getKey(), valuesArray[i]);
+            }
+        }
+	}
+
+	private void addTextParameter(String name, String value){
+		if( ! parametersMap.containsKey( name ) ){
+			String[] valuesArray = {value};
+			parametersMap.put(name, valuesArray);
+		}else{
+			String[] storedValues = (String[])parametersMap.get( name );
+			int lengthSrc = storedValues.length;
+			String[] valuesArray = new String[lengthSrc+1];
+			System.arraycopy(storedValues, 0, valuesArray, 0, lengthSrc);
+			valuesArray[lengthSrc] = value;
+			parametersMap.put(name, valuesArray);
+		}
+	}
+
+	public Enumeration getParameterNames() {
+		if( parametersMap == null ) parseRequest();
+
+		return Collections.enumeration( parametersMap.keySet() );
+	}
+
+	public String getParameter(String name) {
+		if( parametersMap == null ) parseRequest();
+
+		String[] values = (String[])parametersMap.get( name );
+		if( values == null )
+			return null;
+		return values[0];
+	}
+
+	public String[] getParameterValues(String name) {
+		if( parametersMap == null ) parseRequest();
+
+		return (String[])parametersMap.get( name );
+	}
+
+	public Map getParameterMap() {
+		if( parametersMap == null ) parseRequest();
+
+		return parametersMap;
+	}
+
+	// Hook for the x:inputFileUpload tag.
+	public FileItem getFileItem(String fieldName) {
+		if( fileItems == null ) parseRequest();
+
+		return (FileItem) fileItems.get( fieldName );
+	}
+
+	/**
+	 * Not used internaly by MyFaces, but provides a way to handle the uploaded files
+	 * out of MyFaces.
+	 */
+	public Map getFileItems(){
+	    return fileItems;
+	}
+}

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartRequestWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MultipartRequestWrapper.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyFacesResourceHandler.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyFacesResourceHandler.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyFacesResourceHandler.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyFacesResourceHandler.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2005 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 org.apache.myfaces.component.html.util;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Mathias Broekelmann
+ *
+ */
+public class MyFacesResourceHandler implements ResourceHandler
+{
+    private final Class _myfacesCustomComponent;
+    private final String _resource;
+
+    /**
+     * @param myfacesCustomComponent
+     * @param resource
+     */
+    public MyFacesResourceHandler(Class myfacesCustomComponent, String resource)
+    {
+        validateCustomComponent(myfacesCustomComponent);
+        _myfacesCustomComponent = myfacesCustomComponent;
+        _resource = resource;
+    }
+    
+    /**
+     * @see org.apache.myfaces.component.html.util.ResourceHandler#getResourceLoaderClass()
+     */
+    public Class getResourceLoaderClass()
+    {
+        return MyFacesResourceLoader.class;
+    }
+
+    protected void validateCustomComponent(Class myfacesCustomComponent)
+    {
+        if (!myfacesCustomComponent.getName().startsWith(
+                MyFacesResourceLoader.ORG_APACHE_MYFACES_CUSTOM + "."))
+        {
+            throw new IllegalArgumentException(
+                    "expected a myfaces custom component class in package "
+                            + MyFacesResourceLoader.ORG_APACHE_MYFACES_CUSTOM);
+        }
+    }
+
+    /**
+     * @see org.apache.myfaces.component.html.util.ResourceHandler#getResourceUri(javax.faces.context.FacesContext)
+     */
+    public String getResourceUri(FacesContext context)
+    {
+        String className = _myfacesCustomComponent.getName();
+        StringBuffer sb = new StringBuffer();
+        sb
+                .append(className.substring(MyFacesResourceLoader.ORG_APACHE_MYFACES_CUSTOM
+                        .length() + 1));
+        sb.append("/");
+        if (_resource != null)
+        {
+            sb.append(_resource);
+        }
+        return sb.toString();
+    }
+}

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyFacesResourceHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyFacesResourceHandler.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyfacesResourceLoader.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyfacesResourceLoader.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyfacesResourceLoader.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyfacesResourceLoader.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,191 @@
+/*
+ /*
+ * Copyright 2005 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 org.apache.myfaces.component.html.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.ResourceBundle;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.renderkit.html.HTML;
+
+/**
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+class MyFacesResourceLoader implements ResourceLoader
+{
+    protected static final Log log = LogFactory.getLog(MyFacesResourceLoader.class);
+
+    static final String ORG_APACHE_MYFACES_CUSTOM = "org.apache.myfaces.custom";
+
+    private static long lastModified = 0;
+
+    private static long getLastModified()
+    {
+        if (lastModified == 0)
+        {
+            final String format = "yyyy-MM-dd HH:mm:ss Z"; // Must match the one used in the build file
+            final String bundleName = AddResource.class.getName();
+            ResourceBundle resources = ResourceBundle.getBundle(bundleName);
+            String sLastModified = resources.getString("lastModified");
+            try
+            {
+                lastModified = new SimpleDateFormat(format).parse(sLastModified).getTime();
+            }
+            catch (ParseException e)
+            {
+                lastModified = new Date().getTime();
+                log.error("Unparsable lastModified : " + sLastModified);
+            }
+        }
+
+        return lastModified;
+    }
+
+    /**
+     * @see org.apache.myfaces.component.html.util.ResourceLoader#serveResource(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
+     */
+    public void serveResource(HttpServletRequest request, HttpServletResponse response,
+            String resourceUri) throws IOException
+    {
+        String[] uriParts = resourceUri.split("/", 2);
+
+        String component = uriParts[0];
+        if (component == null || component.trim().length() == 0)
+        {
+            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid request");
+            log.error("Could not find parameter for component to load a resource.");
+            return;
+        }
+        Class componentClass;
+        String className = ORG_APACHE_MYFACES_CUSTOM + "." + component;
+        try
+        {
+            componentClass = loadComponentClass(className);
+        }
+        catch (ClassNotFoundException e)
+        {
+            response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
+            log.error("Could not find the class for component " + className
+                    + " to load a resource.");
+            return;
+        }
+        String resource = uriParts[1];
+        if (resource == null || resource.trim().length() == 0)
+        {
+            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No resource defined");
+            log.error("No resource defined component class " + className);
+            return;
+        }
+        resource = "resource/" + resource;
+
+        InputStream is = componentClass.getResourceAsStream(resource);
+        if (is == null)
+        {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, "Unable to find resource "
+                    + resource + " for component " + component
+                    + ". Check that this file is available " + "in the classpath in sub-directory "
+                    + "/resource of the package-directory.");
+            log.error("Unable to find resource " + resource + " for component " + component
+                    + ". Check that this file is available " + "in the classpath in sub-directory "
+                    + "/resource of the package-directory.");
+        }
+        else
+        {
+            defineContentHeaders(request, response, resource);
+            defineCaching(request, response, resource);
+            writeResource(request, response, is);
+        }
+    }
+
+    /**
+     * @param request
+     * @param response
+     * @param in
+     */
+    protected void writeResource(HttpServletRequest request, HttpServletResponse response,
+            InputStream in) throws IOException
+    {
+        ServletOutputStream out = response.getOutputStream();
+        try
+        {
+            byte[] buffer = new byte[1024];
+            for (int size = in.read(buffer); size != -1; size = in.read(buffer))
+            {
+                out.write(buffer, 0, size);
+            }
+        }
+        finally
+        {
+            out.close();
+        }
+    }
+
+    protected void defineCaching(HttpServletRequest request, HttpServletResponse response,
+            String resource)
+    {
+        response.setDateHeader("Last-Modified", getLastModified());
+
+        // Set browser cache to a week.
+        // There is no risk, as the cache key is part of the URL.
+        Calendar expires = Calendar.getInstance();
+        expires.add(Calendar.DAY_OF_YEAR, 7);
+        response.setDateHeader("Expires", expires.getTimeInMillis());
+    }
+
+    protected void defineContentHeaders(HttpServletRequest request, HttpServletResponse response,
+            String resource)
+    {
+        if (resource.endsWith(".js"))
+            response.setContentType(HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT);
+        else if (resource.endsWith(".css"))
+            response.setContentType(HTML.STYLE_TYPE_TEXT_CSS);
+        else if (resource.endsWith(".gif"))
+            response.setContentType("image/gif");
+        else if (resource.endsWith(".png"))
+            response.setContentType("image/png");
+        else if (resource.endsWith(".jpg") || resource.endsWith(".jpeg"))
+            response.setContentType("image/jpeg");
+        else if (resource.endsWith(".xml") || resource.endsWith(".xsl"))
+            response.setContentType("text/xml"); // XSL has to be served as XML.
+    }
+
+    protected Class loadComponentClass(String componentClass) throws ClassNotFoundException
+    {
+        return Thread.currentThread().getContextClassLoader().loadClass(componentClass);
+    }
+
+    protected void validateCustomComponent(Class myfacesCustomComponent)
+    {
+        if (!myfacesCustomComponent.getName().startsWith(ORG_APACHE_MYFACES_CUSTOM + "."))
+        {
+            throw new IllegalArgumentException(
+                    "expected a myfaces custom component class in package "
+                            + ORG_APACHE_MYFACES_CUSTOM);
+        }
+    }
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyfacesResourceLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/MyfacesResourceLoader.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ParameterResourceHandler.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ParameterResourceHandler.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ParameterResourceHandler.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ParameterResourceHandler.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2005 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 org.apache.myfaces.component.html.util;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+/**
+ * @author Mathias Broekelmann
+ *
+ */
+public class ParameterResourceHandler implements ResourceHandler
+{
+    private final Map _parameters;
+    private final Class _resourceLoaderClass;
+
+    private Integer _hashCode;
+
+    /**
+     * @param resourceLoaderClass
+     * @param parameters
+     */
+    public ParameterResourceHandler(Class resourceLoaderClass, Map parameters)
+    {
+        _resourceLoaderClass = resourceLoaderClass;
+        _parameters = parameters;
+    }
+
+    /**
+     * @see org.apache.myfaces.component.html.util.ResourceHandler#getResourceLoaderClass()
+     */
+    public Class getResourceLoaderClass()
+    {
+        return _resourceLoaderClass;
+    }
+
+    /**
+     * @see org.apache.myfaces.component.html.util.ResourceHandler#getResourceUri(javax.faces.context.FacesContext)
+     */
+    public String getResourceUri(FacesContext context)
+    {
+        if (_parameters != null && !_parameters.isEmpty())
+        {
+            StringBuffer sb = new StringBuffer();
+            sb.append("?");
+            for (Iterator iter = _parameters.entrySet().iterator(); iter.hasNext();)
+            {
+                Map.Entry entry = (Map.Entry) iter.next();
+                sb.append(entry.getKey());
+                sb.append("=");
+                sb.append(entry.getValue());
+                if (iter.hasNext())
+                {
+                    sb.append("&");
+                }
+            }
+            return sb.toString();
+        }
+        return null;
+    }
+
+    /**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object obj)
+    {
+        if (obj == null)
+        {
+            return false;
+        }
+        if (obj == this)
+        {
+            return true;
+        }
+        if (obj instanceof ParameterResourceHandler)
+        {
+            ParameterResourceHandler other = (ParameterResourceHandler) obj;
+            return new EqualsBuilder().append(_parameters, other._parameters).isEquals();
+        }
+        return false;
+    }
+
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        if (_hashCode == null)
+        {
+            _hashCode = new Integer(new HashCodeBuilder().append(_parameters).toHashCode());
+        }
+        return _hashCode.intValue();
+    }
+}

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ParameterResourceHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ParameterResourceHandler.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2004 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 org.apache.myfaces.component.html.util;
+
+/**
+ * @author Martin Marinschek
+ * @version $Revision$ $Date$
+ */
+public class ReducedHTMLParser
+{
+    public static final int BODY_TAG = 0;
+    public static final int HEAD_TAG = 1;
+    public static final int SCRIPT_TAG = 2;
+
+    public static void parse(CharSequence seq, CallbackListener l)
+    {
+        char[] lastChars = new char[10];
+        int currentTagIdentifier = -1;
+        boolean openedTag = false;
+        boolean openedStartTag=false;
+        int openedTagIndex=-1;
+        boolean closeSymbolEncountered = false;
+        boolean commentMode = false;
+        boolean attributeMode = false;
+        char attributeOpenChar = 0;
+        boolean scriptMode = false;
+
+
+        for(int i=0; i<seq.length();i++)
+        {
+            char c = seq.charAt(i);
+
+            if(!commentMode && !attributeMode &&
+                    lastChars[2]=='-' &&
+                        lastChars[1]=='-' &&
+                            lastChars[0]=='!' &&
+                                c=='>')
+            {
+                commentMode = true;
+            }
+            else if(commentMode && !attributeMode &&
+                    lastChars[1]=='<' &&
+                            lastChars[0]=='-' &&
+                                c=='-')
+            {
+                commentMode = false;
+            }
+            else if (!commentMode)
+            {
+                if(!scriptMode && !attributeMode && !openedTag && c=='<')
+                {
+                    openedTag = true;
+                    openedTagIndex = i;
+                }
+                else if(!scriptMode && !attributeMode && openedTag && c=='>')
+                {
+                    if(currentTagIdentifier != -1)
+                    {
+                        if(openedStartTag)
+                        {
+                            l.closedStartTag(i,currentTagIdentifier);
+
+                            if(closeSymbolEncountered)
+                            {
+                                if(currentTagIdentifier==SCRIPT_TAG)
+                                    scriptMode = false;
+
+                                l.closedEndTag(i,currentTagIdentifier);
+                            }
+                        }
+                        else
+                        {
+                            if(currentTagIdentifier==SCRIPT_TAG)
+                                scriptMode = false;
+
+                            l.closedEndTag(i,currentTagIdentifier);
+                        }
+                    }
+
+                    openedTagIndex = -1;
+                    openedTag = false;
+                    openedStartTag = false;
+                    currentTagIdentifier = -1;
+                    closeSymbolEncountered = false;
+                }
+                else if(!scriptMode && openedTag && !attributeMode && (c=='"' || c=='\''))
+                {
+                    attributeMode = true;
+                    attributeOpenChar = c;
+                }
+                else if(!scriptMode && openedTag && attributeMode && (c=='"' || c=='\'') && lastChars[0]!='\\')
+                {
+                    if(c==attributeOpenChar)
+                    {
+                        attributeMode = false;
+                    }
+                }
+                else if(!scriptMode && !attributeMode && openedTag && c=='/')
+                {
+                    closeSymbolEncountered = true;
+                }
+                else if(!scriptMode && !attributeMode && openedTag &&
+                        (lastChars[2]=='b' || lastChars[2]=='B') &&
+                            (lastChars[1]=='o' || lastChars[1]=='O') &&
+                                (lastChars[0]=='d' || lastChars[0]=='D') &&
+                                    (c=='y' || c=='Y'))
+                {
+                    currentTagIdentifier = BODY_TAG;
+
+                    openedStartTag = handleTag(closeSymbolEncountered, l, openedTagIndex, openedStartTag,
+                            currentTagIdentifier);
+
+
+                }
+                else if(!scriptMode && !attributeMode && openedTag &&
+                        (lastChars[3]=='<' || Character.isWhitespace(lastChars[3])) && // Added this to make sure it's not <thead> this was messing up in screen with datatable
+                        (lastChars[2]=='h' || lastChars[2]=='H') &&
+                            (lastChars[1]=='e' || lastChars[1]=='E')&&
+                                (lastChars[0]=='a' || lastChars[1]=='A')&&
+                                    (c=='d' || c=='D'))
+                {
+                    currentTagIdentifier = HEAD_TAG;
+
+                    openedStartTag = handleTag(closeSymbolEncountered, l, openedTagIndex, openedStartTag,
+                            currentTagIdentifier);
+                }
+                else if(!attributeMode && openedTag &&
+                    (lastChars[4]=='s' || lastChars[4]=='S') &&
+                        (lastChars[3]=='c' || lastChars[3]=='C') &&
+                            (lastChars[2]=='r' || lastChars[2]=='R') &&
+                                (lastChars[1]=='i' || lastChars[1]=='I')&&
+                                    (lastChars[0]=='p' || lastChars[0]=='P')&&
+                                        (c=='t' || c=='T'))
+                {
+                    currentTagIdentifier = SCRIPT_TAG;
+
+                    scriptMode = true;
+
+                    openedStartTag = handleTag(closeSymbolEncountered, l,
+                            openedTagIndex, openedStartTag, currentTagIdentifier);
+                }
+            }
+
+            lastChars[9]=lastChars[8];
+            lastChars[8]=lastChars[7];
+            lastChars[7]=lastChars[6];
+            lastChars[6]=lastChars[5];
+            lastChars[5]=lastChars[4];
+            lastChars[4]=lastChars[3];
+            lastChars[3]=lastChars[2];
+            lastChars[2]=lastChars[1];
+            lastChars[1]=lastChars[0];
+            lastChars[0]=c;
+        }
+    }
+
+    private static boolean handleTag(boolean closeSymbolEncountered, CallbackListener l,
+                                     int openedTagIndex, boolean openedStartTag, int currentTagIdentifier)
+    {
+        if(closeSymbolEncountered)
+        {
+            l.openedEndTag(openedTagIndex,currentTagIdentifier);
+        }
+        else
+        {
+            l.openedStartTag(openedTagIndex,currentTagIdentifier);
+            openedStartTag = true;
+        }
+        return openedStartTag;
+    }
+
+    public static void main(String[] args)
+    {
+        ReducedHTMLParser.parse(new StringBuffer("<html><head></head><body =\"xx'<body/>'x\"><xxx></xxx></body></html"),new CallbackListener(){
+            public void openedStartTag(int charIndex, int tagIdentifier)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
+            }
+
+            public void closedStartTag(int charIndex, int tagIdentifier)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
+            }
+
+            public void openedEndTag(int charIndex, int tagIdentifier)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
+            }
+
+            public void closedEndTag(int charIndex, int tagIdentifier)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
+            }
+
+            public void attribute(int charIndex, int tagIdentifier, String key, String value)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
+            }
+        });
+    }
+}

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceHandler.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceHandler.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceHandler.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceHandler.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2005 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 org.apache.myfaces.component.html.util;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 
+ * @author Mathias Broekelmann
+ *
+ */
+public interface ResourceHandler
+{
+    /**
+     * Returns the resource loader class which is used to load the resource 
+     * 
+     * @return
+     */
+    Class getResourceLoaderClass(); 
+    
+    /**
+     * Returns the uri part which is used by the resourceloader to identify the resource to load. 
+     * 
+     * @param context
+     * @return the returned resource uri will be passed as the resourceUri parameter for 
+     * the ResourceLoader.serveResource method (omitting request parameters) 
+     * @see ResourceLoader#serveResource(HttpServletRequest, HttpServletResponse, String)
+     */
+    String getResourceUri(FacesContext context);
+    
+    /**
+     * must be implemented to avoid loading the same resource multiple times.
+     * 
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode();
+    
+    /**
+     * must be implemented to avoid loading the same resource multiple times.
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object obj);
+}

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceHandler.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceLoader.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceLoader.java?rev=328404&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceLoader.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceLoader.java Tue Oct 25 09:21:17 2005
@@ -0,0 +1,39 @@
+/*
+ /*
+ * Copyright 2005 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 org.apache.myfaces.component.html.util;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public interface ResourceLoader
+{
+    /**
+     * @param request the request 
+     * @param response the response to write the resource content to
+     * @param resourceUri contains the uri part after the uri which 
+     * is used to identify the resource loader
+     * 
+     * @throws IOException
+     */
+    void serveResource(HttpServletRequest request, HttpServletResponse response, String resourceUri) throws IOException;
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ResourceLoader.java
------------------------------------------------------------------------------
    svn:keywords = URL Author Revision Date

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java Tue Oct 25 09:21:17 2005
@@ -259,20 +259,20 @@
         {
             return;
         }
-
+        AddResource addresource = AddResource.getInstance(facesContext);
         // Add the javascript and CSS pages
-        AddResource.addStyleSheet(HtmlCalendarRenderer.class, "WH/theme.css", facesContext);
-        AddResource.addStyleSheet(HtmlCalendarRenderer.class, "DB/theme.css", facesContext);
-        AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class, "prototype.js", facesContext);
-        AddResource.addJavaScriptToHeader(HtmlCalendarRenderer.class, "date.js", facesContext);
-        AddResource.addJavaScriptToHeader(HtmlCalendarRenderer.class, "popcalendar_init.js", facesContext);
+        addresource.addStyleSheet(facesContext, HtmlCalendarRenderer.class, "WH/theme.css");
+        addresource.addStyleSheet(facesContext, HtmlCalendarRenderer.class, "DB/theme.css");
+        addresource.addJavaScriptToHeader(facesContext, PrototypeResourceLoader.class, "prototype.js");
+        addresource.addJavaScriptToHeader(facesContext, HtmlCalendarRenderer.class, "date.js");
+        addresource.addJavaScriptToHeader(facesContext, HtmlCalendarRenderer.class, "popcalendar_init.js");
 
         StringBuffer imageScript = new StringBuffer();
         appendImageDirectory(imageScript, facesContext);
-        AddResource.addInlineScriptToHeader(imageScript.toString(),facesContext);
-        AddResource.addInlineScriptToHeader(getLocalizedLanguageScript(symbols,months,firstDayOfWeek,
-                uiComponent),facesContext);
-        AddResource.addJavaScriptToHeader(HtmlCalendarRenderer.class, "popcalendar.js", facesContext);
+        addresource.addInlineScriptToHeader(facesContext, imageScript.toString());
+        addresource.addInlineScriptToHeader(facesContext, getLocalizedLanguageScript(symbols,months,firstDayOfWeek,
+                                        uiComponent));
+        addresource.addJavaScriptToHeader(facesContext, HtmlCalendarRenderer.class, "popcalendar.js");
 
         ResponseWriter writer = facesContext.getResponseWriter();
 
@@ -290,8 +290,8 @@
     private static void appendImageDirectory(StringBuffer script, FacesContext facesContext)
     {
         script.append("jscalendarSetImageDirectory('");
-        script.append(JavascriptUtils.encodeString(
-                AddResource.getResourceMappedPath(HtmlCalendarRenderer.class, "DB/", facesContext)
+        script.append(JavascriptUtils.encodeString(AddResource.getInstance(facesContext)
+                .getResourceUri(facesContext, HtmlCalendarRenderer.class, "DB/")
         ));
         script.append("');");
     }
@@ -438,7 +438,8 @@
         } else {
             // render the image
             writer.startElement(HTML.IMG_ELEM, uiComponent);
-            writer.writeAttribute(HTML.SRC_ATTR, AddResource.getResourceMappedPath(HtmlCalendarRenderer.class, "images/calendar.gif", facesContext), null);
+            AddResource addResource = AddResource.getInstance(facesContext);
+            writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, HtmlCalendarRenderer.class, "images/calendar.gif"), null);
             writer.writeAttribute(HTML.STYLE_ATTR, "vertical-align:bottom;", null);
 
             //writer.writeAttribute(HTML.ONCLICK_ATTR, "document.getElementById(\\'"+buttonId+"\\').click()",null);

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java Tue Oct 25 09:21:17 2005
@@ -124,34 +124,36 @@
             formId = tmpComponent.getClientId(context);
         }
 
-
-        AddResource.addStyleSheet(InputHtmlRenderer.class, "kupustyles.css", context);
-        AddResource.addStyleSheet(InputHtmlRenderer.class, "kupudrawerstyles.css", context);
-        AddResource.addStyleSheet(InputHtmlRenderer.class, "myFaces.css", context);
-
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "sarissa.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "sarissa_ieemu_xpath.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupuhelpers.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupueditor.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupubasetools.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupuloggers.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupunoi18n.js", context);
-        //AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "i18n/i18n.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupucleanupexpressions.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupucontentfilters.js", context);
+        AddResource addResource = AddResource.getInstance(context);
+        addResource.addStyleSheet(context, InputHtmlRenderer.class, "kupustyles.css");
+        addResource.addStyleSheet(context, InputHtmlRenderer.class, "kupudrawerstyles.css");
+        addResource.addStyleSheet(context, InputHtmlRenderer.class, "myFaces.css");
+
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "sarissa.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "sarissa_ieemu_xpath.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupuhelpers.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupueditor.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupubasetools.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupuloggers.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupunoi18n.js");
+        //addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "i18n/i18n.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupucleanupexpressions.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupucontentfilters.js");
         
-        if( editor.isShowAnyToolBox() )
-        	AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kuputoolcollapser.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupucontextmenu.js", context);
+        if (editor.isShowAnyToolBox())
+        {
+            addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kuputoolcollapser.js");
+        }
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupucontextmenu.js");
         
-		AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupuinit.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupustart.js", context);
+		addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupuinit.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupustart.js");
         
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupusourceedit.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupuspellchecker.js", context);
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupudrawers.js", context);
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupusourceedit.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupuspellchecker.js");
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "kupudrawers.js");
         
-        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "myFacesUtils.js", context);
+        addResource.addJavaScriptToHeader(context, InputHtmlRenderer.class, "myFacesUtils.js");
         
         ResponseWriter writer = context.getResponseWriter();
 
@@ -223,12 +225,12 @@
 					  writer.endElement("set");
 		            writer.endElement("cleanup_expressions");
 
-					writeTag(writer, "image_xsl_uri", AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupudrawers/drawer.xsl", context), editor);
-					writeTag(writer, "link_xsl_uri", AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupudrawers/drawer.xsl", context), editor);
+					writeTag(writer, "image_xsl_uri", addResource.getResourceUri(context, InputHtmlRenderer.class, "kupudrawers/drawer.xsl"), editor);
+					writeTag(writer, "link_xsl_uri", addResource.getResourceUri(context, InputHtmlRenderer.class, "kupudrawers/drawer.xsl"), editor);
 
 					// TODO : Make this work (reference available images, ...).
-					writeTag(writer, "image_libraries_uri", AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupudrawers/imagelibrary.xml", context), editor);
-					writeTag(writer, "link_libraries_uri", AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupudrawers/linklibrary.xml", context), editor);
+					writeTag(writer, "image_libraries_uri", addResource.getResourceUri(context, InputHtmlRenderer.class, "kupudrawers/imagelibrary.xml"), editor);
+					writeTag(writer, "link_libraries_uri", addResource.getResourceUri(context, InputHtmlRenderer.class, "kupudrawers/linklibrary.xml"), editor);
 	        		writeTag(writer, "search_images_uri", "", editor);
 	        		writeTag(writer, "search_links_uri", "", editor);
 
@@ -529,7 +531,7 @@
                                     writer.writeAttribute(HTML.WIDTH_ATTR, "440", null);
                                     writer.writeAttribute(HTML.HEIGHT_ATTR, "198", null);
                                     writer.writeAttribute(HTML.CLASS_ATTR, "kupu-linkdrawer-preview", null);
-                                    writer.writeAttribute(HTML.SRC_ATTR, AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupublank.html", context), null);
+                                    writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(context, InputHtmlRenderer.class, "kupublank.html"), null);
                                     writer.endElement(HTML.IFRAME_ELEM);
                                 writer.endElement(HTML.TD_ELEM);
                             writer.endElement(HTML.TR_ELEM);
@@ -1098,10 +1100,10 @@
             }
             if( editor.getStyle()!=null ){
                 // Convert the style into an style declaration so that it doesn't preempt the Zoom works as it's relying on changing the class
-                AddResource.addInlineStyleToHeader(
+                addResource.addInlineStyleToHeader(
+                        context,
 						"#kupu-editor{height: inherit;}\n"+
-						"div.kupu-fulleditor{"+editor.getStyle()+"}",
-						context);
+						"div.kupu-fulleditor{"+editor.getStyle()+"}");
             }
             writer.writeAttribute(HTML.CLASS_ATTR,
                     "kupu-editorframe"+(editor.getStyleClass()==null ? "" : " "+editor.getStyleClass()), null);
@@ -1130,7 +1132,7 @@
         String text = editor.getValueAsHtmlDocument( context );
         String encodedText = text == null ? "" : JavascriptUtils.encodeString( text );
 
-        String resourceBaseURL = AddResource.getResourceMappedPath(InputHtmlRenderer.class, "", context);
+        String resourceBaseURL = addResource.getResourceUri(context, InputHtmlRenderer.class, null);
 
         writer.startElement(HTML.SCRIPT_ELEM, editor);
         writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRenderer.java Tue Oct 25 09:21:17 2005
@@ -162,8 +162,7 @@
 
     private static void addJavaScriptResources(FacesContext facesContext)
     {
-        AddResource.addJavaScriptToHeader(HtmlTextHelpRenderer.class,
-                                            "inputTextHelp.js",
-                                            facesContext);
+        AddResource.getInstance(facesContext).addJavaScriptToHeader(
+                facesContext, HtmlTextHelpRenderer.class, "inputTextHelp.js");
     }
 }

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/jslistener/JsValueChangeListenerRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/jslistener/JsValueChangeListenerRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/jslistener/JsValueChangeListenerRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/jslistener/JsValueChangeListenerRenderer.java Tue Oct 25 09:21:17 2005
@@ -38,8 +38,9 @@
         String expressionValue = jsValueChangeListener.getExpressionValue();
         String property = jsValueChangeListener.getProperty();
 
-        AddResource.addJavaScriptToHeader(
-                JsValueChangeListenerTag.class, "JSListener.js", false, getFacesContext());
+        AddResource.getInstance(facesContext).addJavaScriptToHeader(
+                facesContext, JsValueChangeListenerRenderer.class,
+                "JSListener.js");
 
         if(aFor!=null)
         {

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java Tue Oct 25 09:21:17 2005
@@ -22,6 +22,7 @@
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIForm;
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import javax.faces.el.MethodBinding;
@@ -32,6 +33,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.component.html.util.AddResource;
+import org.apache.myfaces.component.html.util.ParameterResourceHandler;
 import org.apache.myfaces.custom.navmenu.NavigationMenuItem;
 import org.apache.myfaces.custom.navmenu.NavigationMenuUtils;
 import org.apache.myfaces.custom.navmenu.UINavigationMenuItem;
@@ -52,16 +54,21 @@
 public class HtmlJSCookMenuRenderer
     extends HtmlRenderer
 {
+    private static final String MYFACES_HACK_SCRIPT = "MyFacesHack.js";
+
+    private static final String JSCOOK_MENU_SCRIPT = "JSCookMenu.js";
+    
+    //private static final Log log = LogFactory.getLog(HtmlJSCookMenuRenderer.class);
     private static final Log log = LogFactory.getLog(HtmlJSCookMenuRenderer.class);
 
     private static final String JSCOOK_ACTION_PARAM = "jscook_action";
 
     private static final Map builtInThemes = new java.util.HashMap();
     static {
-        builtInThemes.put("ThemeOffice", "/ThemeOffice/");
-        builtInThemes.put("ThemeMiniBlack", "/ThemeMiniBlack/");
-        builtInThemes.put("ThemeIE", "/ThemeIE/");
-        builtInThemes.put("ThemePanel", "/ThemePanel/");
+        builtInThemes.put("ThemeOffice", "ThemeOffice/");
+        builtInThemes.put("ThemeMiniBlack", "ThemeMiniBlack/");
+        builtInThemes.put("ThemeIE", "ThemeIE/");
+        builtInThemes.put("ThemePanel", "ThemePanel/");
     }
     
     public void decode(FacesContext context, UIComponent component)
@@ -362,16 +369,18 @@
         String javascriptLocation = (String) menu.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
         String imageLocation = (String) menu.getAttributes().get(JSFAttr.IMAGE_LOCATION);
         String styleLocation = (String) menu.getAttributes().get(JSFAttr.STYLE_LOCATION);
+        
+        AddResource addResource = AddResource.getInstance(context);
 
         if(javascriptLocation != null)
         {
-            AddResource.addJavaScriptToHeader(javascriptLocation, "JSCookMenu.js", context);
-            AddResource.addJavaScriptToHeader(javascriptLocation, "MyFacesHack.js", context);
+            addResource.addJavaScriptToHeader(context, javascriptLocation + "/" + JSCOOK_MENU_SCRIPT);
+            addResource.addJavaScriptToHeader(context, javascriptLocation + "/" + MYFACES_HACK_SCRIPT);
         }
         else
         {
-            AddResource.addJavaScriptToHeader(HtmlJSCookMenuRenderer.class, "JSCookMenu.js", context);
-            AddResource.addJavaScriptToHeader(HtmlJSCookMenuRenderer.class, "MyFacesHack.js", context);
+            addResource.addJavaScriptToHeader(context, HtmlJSCookMenuRenderer.class, JSCOOK_MENU_SCRIPT);
+            addResource.addJavaScriptToHeader(context, HtmlJSCookMenuRenderer.class, MYFACES_HACK_SCRIPT);
         }
 
         addThemeSpecificResources(themeName, styleLocation, javascriptLocation, imageLocation, context);
@@ -420,7 +429,10 @@
             log.debug("Unknown theme name '" + themeName + "' specified.");
         }
 
-        if ((imageLocation != null) || (themeLocation != null)) {
+        AddResource addResource = AddResource.getInstance(context);
+
+        if ((imageLocation != null) || (themeLocation != null))
+        {
             // Generate a javascript variable containing a reference to the
             // directory containing theme image files, for use by the theme
             // javascript file. If neither of these is defined (ie a custom
@@ -431,51 +443,58 @@
             buf.append("var my");
             buf.append(themeName);
             buf.append("Base='");
-            if(imageLocation!=null)
+            ExternalContext externalContext = context.getExternalContext();
+            if (imageLocation != null)
             {
-                buf.append(AddResource.getResourceBasePath(imageLocation+themeName));
+                buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
+                        imageLocation + "/" + themeName)));
             }
             else
             {
-                buf.append(AddResource.getResourceBasePath(HtmlJSCookMenuRenderer.class,context));
-                buf.append(themeLocation);
+                buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
+                        HtmlJSCookMenuRenderer.class, themeLocation)));
             }
-            buf.append( "';");
-
-            AddResource.addInlineScriptToHeader(buf.toString(), context);
+            buf.append("';");
+            addResource.addInlineScriptToHeader(context, buf.toString());
         }
 
-        if ((javascriptLocation != null) || (themeLocation != null)) {
+
+        if ((javascriptLocation != null) || (themeLocation != null))
+        {
             // Generate a <script> tag in the page header pointing to the
             // theme.js file for this theme. If neither of these is defined
             // then presumably the theme.js file is referenced by a <script>
             // tag hard-wired into the page or inserted via some other means.
-            if(javascriptLocation != null)
+            if (javascriptLocation != null)
             {
                 // For now, assume that if the user specified a location for a custom
                 // version of the jscookMenu.js file then the theme.js file can be found
                 // in the same location.
-                AddResource.addJavaScriptToHeader(javascriptLocation, themeName+"/theme.js", context);
+                addResource.addJavaScriptToHeader(context, javascriptLocation + "/" + themeName
+                        + "/theme.js");
             }
             else
             {
                 // Using a built-in theme, so we know where the theme.js file is.
-                AddResource.addJavaScriptToHeader(HtmlJSCookMenuRenderer.class, themeName+"/theme.js", context);
+                addResource.addJavaScriptToHeader(context, HtmlJSCookMenuRenderer.class, themeName
+                        + "/theme.js");
             }
         }
 
-        if ((styleLocation != null) || (themeLocation != null)) {
+        if ((styleLocation != null) || (themeLocation != null))
+        {
             // Generate a <link type="text/css"> tag in the page header pointing to
             // the theme stylesheet. If neither of these is defined then presumably
             // the stylesheet is referenced by a <link> tag hard-wired into the page
             // or inserted via some other means.
-            if(styleLocation != null)
+            if (styleLocation != null)
             {
-                AddResource.addStyleSheet(styleLocation, themeName+"/theme.css", context);
+                addResource.addStyleSheet(context, styleLocation + "/" + themeName + "/theme.css");
             }
             else
             {
-                AddResource.addStyleSheet(HtmlJSCookMenuRenderer.class, themeName+"/theme.css", context);
+                addResource.addStyleSheet(context, HtmlJSCookMenuRenderer.class, themeName
+                        + "/theme.css");
             }
         }
     }

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java Tue Oct 25 09:21:17 2005
@@ -112,8 +112,7 @@
                                     Integer displayAtDistanceX, Integer displayAtDistanceY, UIComponent uiComponent)
         throws IOException
     {
-        AddResource.addJavaScriptToHeader(
-                HtmlPopupRenderer.class, "JSPopup.js", false, context);
+        AddResource.getInstance(context).addJavaScriptToHeader(context, HtmlPopupRenderer.class, "JSPopup.js");
 
         String popupId = (clientId+"Popup").replaceAll(":","_");
 

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/swapimage/HtmlSwapImageRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/swapimage/HtmlSwapImageRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/swapimage/HtmlSwapImageRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/swapimage/HtmlSwapImageRenderer.java Tue Oct 25 09:21:17 2005
@@ -17,12 +17,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.component.html.util.AddResource;
 import org.apache.myfaces.renderkit.JSFAttr;
 import org.apache.myfaces.renderkit.RendererUtils;
 import org.apache.myfaces.renderkit.html.HTML;
 import org.apache.myfaces.renderkit.html.HtmlRenderer;
 import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.component.html.util.AddResource;
 import org.apache.myfaces.custom.navigation.HtmlCommandNavigation;
 
 import javax.faces.component.UIComponent;
@@ -47,7 +47,8 @@
 
         ResponseWriter writer = facesContext.getResponseWriter();
 
-        AddResource.addJavaScriptToHeader(HtmlSwapImage.class, "swapimage.js", facesContext);
+        AddResource.getInstance(facesContext).addJavaScriptToHeader(facesContext,
+                HtmlSwapImage.class, "swapimage.js");
 
         String url;
         if (uiComponent instanceof HtmlSwapImage)

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java Tue Oct 25 09:21:17 2005
@@ -91,17 +91,18 @@
             tabbedPane.setBgcolor(DEFAULT_BG_COLOR);
         }
         
-        AddResource.addStyleSheet(HtmlTabbedPaneRenderer.class, "defaultStyles.css", facesContext);
+        AddResource addResource = AddResource.getInstance(facesContext);
+        addResource.addStyleSheet(facesContext, HtmlTabbedPaneRenderer.class, "defaultStyles.css");
 
         if( isDynamic() ){
-        	AddResource.addJavaScriptToHeader(HtmlTabbedPaneRenderer.class, "dynamicTabs.js", facesContext);
-        	AddResource.addInlineStyleToHeader(
+            addResource.addJavaScriptToHeader(facesContext, HtmlTabbedPaneRenderer.class, "dynamicTabs.js");
+            addResource.addInlineStyleToHeader(facesContext,
         			'#'+getTableStylableId(tabbedPane,facesContext)+" ."+ACTIVE_HEADER_CELL_CLASS+" input,\n" +
         			'#'+getTableStylableId(tabbedPane,facesContext)+" ."+TAB_PANE_CLASS+",\n" +
         			'#'+getTableStylableId(tabbedPane,facesContext)+" ."+SUB_HEADER_CELL_CLASS+"{\n"+
         				"background-color:" + tabbedPane.getBgcolor()+";\n"+
-        			"}\n",
-        			facesContext);
+        			"}\n"
+        			);
         }
         
         



Mime
View raw message