myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmarinsc...@apache.org
Subject cvs commit: incubator-myfaces/webapps/examples/web popup.jsp .cvsignore sample2.jsp
Date Tue, 16 Nov 2004 16:25:53 GMT
mmarinschek    2004/11/16 08:25:53

  Modified:    build/codegen .cvsignore build.xml
               conf/tiles develop-web.xml
               conf     develop-web.xml faces-config.xml web.xml
               src/codegen/org/apache/myfaces/codegen/component
                        ComponentGeneratorTask.java
               src/components/org/apache/myfaces/custom/fileupload
                        MultipartFilter.java MultipartRequestWrapper.java
               tlds     myfaces_ext.tld
               webapps/examples/src/org/apache/myfaces/examples/resource
                        example_messages.properties
                        example_messages_de.properties
                        example_messages_fr.properties
                        example_messages_ja.properties
               webapps/examples/web/WEB-INF examples-config.xml
               webapps/examples/web/inc head.inc navigation.jsp
                        page_header.jsp
               webapps/examples/web .cvsignore sample2.jsp
  Added:       build/codegen build.default.properties
               src/components/org/apache/myfaces/custom/popup
                        HtmlPopup.java HtmlPopup.xml HtmlPopupRenderer.java
                        HtmlPopupTag.java
               src/components_resource/jspopup JSPopup.js
               webapps/examples/web popup.jsp
  Removed:     build/codegen build.properties.sample
  Log:
  new popup - component; not yet finished
  
  Revision  Changes    Path
  1.2       +1 -0      incubator-myfaces/build/codegen/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/build/codegen/.cvsignore,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- .cvsignore	9 Mar 2004 13:23:59 -0000	1.1
  +++ .cvsignore	16 Nov 2004 16:25:52 -0000	1.2
  @@ -1,2 +1,3 @@
   velocity.log
   build.properties
  +build.local.properties
  
  
  
  1.13      +5 -3      incubator-myfaces/build/codegen/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/build/codegen/build.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- build.xml	29 Oct 2004 15:50:59 -0000	1.12
  +++ build.xml	16 Nov 2004 16:25:52 -0000	1.13
  @@ -11,9 +11,10 @@
       <property name="components-src.dir" location="${project.dir}/src/components"/>
   
       <!-- Properties -->
  -    <property file="build.properties"/>
  -    <property file="../build.properties"/>
  -    <property file="../build.properties.default"/>
  +    <property file="build.local.properties"/>
  +    <property file="build.default.properties"/>
  +    <property file="../build.local.properties"/>
  +    <property file="../build.default.properties"/>
       <property file="../manifest.properties"/>
   
       <!-- Temporary dir. May be overridden in build.properties -->
  @@ -26,6 +27,7 @@
           <pathelement location="${ant.jar}"/>
           <pathelement location="${velocity.jar}"/>
           <pathelement location="${sun-jsf-api.jar}"/>
  +        <pathelement location="${commons-logging.jar}"/>                
           <pathelement location="${codegen-classes.dir}"/>
       </path>
   
  
  
  
  1.1                  incubator-myfaces/build/codegen/build.default.properties
  
  Index: build.default.properties
  ===================================================================
  
  ant.jar = C:\\Develop\\Tools\\apache-ant-1.6.1\\lib\\ant.jar
  velocity.jar = C:\\java\\velocity\\velocity-dep-1.4.jar
  sun-jsf-api.jar = C:\\Develop\\jsf-1_0\\lib\\jsf-api.jar 
  
  single-component = javax/faces/component/UIComponentBase
  
  
  
  
  1.5       +29 -0     incubator-myfaces/conf/tiles/develop-web.xml
  
  Index: develop-web.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/conf/tiles/develop-web.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- develop-web.xml	29 Oct 2004 15:50:59 -0000	1.4
  +++ develop-web.xml	16 Nov 2004 16:25:52 -0000	1.5
  @@ -111,6 +111,35 @@
       <filter>
           <filter-name>multipartFilter</filter-name>
           <filter-class>org.apache.myfaces.custom.fileupload.MultipartFilter</filter-class>
  +        <init-param>
  +            <param-name>maxFileSize</param-name>
  +            <param-value>100m</param-value>
  +            <description>Set the size limit for uploaded files.
  +                Format: 10 - 10 bytes
  +                        10k - 10 KB
  +                        10m - 10 MB
  +                        1g - 1 GB
  +            </description>
  +        </init-param>
  +        <init-param>
  +            <param-name>thresholdSize</param-name>
  +            <param-value>100k</param-value>
  +            <description>Set the threshold size - files
  +                    below this limit are stored in memory, files above
  +                    this limit are stored on disk.
  +
  +                Format: 10 - 10 bytes
  +                        10k - 10 KB
  +                        10m - 10 MB
  +                        1g - 1 GB
  +            </description>
  +        </init-param>
  +<!--        <init-param>
  +            <param-name>repositoryPath</param-name>
  +            <param-value>/temp</param-value>
  +            <description>Set the path where the intermediary files will be stored.
  +            </description>
  +        </init-param>-->
       </filter>
   
   
  
  
  
  1.20      +30 -1     incubator-myfaces/conf/develop-web.xml
  
  Index: develop-web.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/conf/develop-web.xml,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- develop-web.xml	29 Oct 2004 15:50:59 -0000	1.19
  +++ develop-web.xml	16 Nov 2004 16:25:52 -0000	1.20
  @@ -117,6 +117,35 @@
       <filter>
           <filter-name>multipartFilter</filter-name>
           <filter-class>org.apache.myfaces.custom.fileupload.MultipartFilter</filter-class>
  +        <init-param>
  +            <param-name>maxFileSize</param-name>
  +            <param-value>100m</param-value>
  +            <description>Set the size limit for uploaded files.
  +                Format: 10 - 10 bytes
  +                        10k - 10 KB
  +                        10m - 10 MB
  +                        1g - 1 GB
  +            </description>
  +        </init-param>
  +        <init-param>
  +            <param-name>thresholdSize</param-name>
  +            <param-value>100k</param-value>
  +            <description>Set the threshold size - files
  +                    below this limit are stored in memory, files above
  +                    this limit are stored on disk.
  +
  +                Format: 10 - 10 bytes
  +                        10k - 10 KB
  +                        10m - 10 MB
  +                        1g - 1 GB
  +            </description>
  +        </init-param>
  +<!--        <init-param>
  +            <param-name>repositoryPath</param-name>
  +            <param-value>/temp</param-value>
  +            <description>Set the path where the intermediary files will be stored.
  +            </description>
  +        </init-param>-->
       </filter>
   
   
  @@ -187,7 +216,7 @@
       </taglib>
   
       <taglib>
  -        <taglib-uri>http://myfaces.apache.org/tld/myfaces_ext_1_0.tld</taglib-uri>
  +        <taglib-uri>http://myfaces.apache.org/extensions</taglib-uri>
           <taglib-location>lib/myfaces_ext.tld</taglib-location>
       </taglib>
   
  
  
  
  1.96      +11 -0     incubator-myfaces/conf/faces-config.xml
  
  Index: faces-config.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/conf/faces-config.xml,v
  retrieving revision 1.95
  retrieving revision 1.96
  diff -u -r1.95 -r1.96
  --- faces-config.xml	8 Nov 2004 20:43:15 -0000	1.95
  +++ faces-config.xml	16 Nov 2004 16:25:52 -0000	1.96
  @@ -196,6 +196,11 @@
           <component-class>org.apache.myfaces.custom.panelstack.HtmlPanelStack</component-class>
       </component>
   
  +    <component>
  +        <component-type>org.apache.myfaces.HtmlPopup</component-type>
  +        <component-class>org.apache.myfaces.custom.popup.HtmlPopup</component-class>
  +    </component>
  +
     <component>
         <component-type>org.apache.myfaces.RssTicker</component-type>
         <component-class>org.apache.myfaces.custom.rssticker.HtmlRssTicker</component-class>
  @@ -358,6 +363,12 @@
               <component-family>javax.faces.Input</component-family>
               <renderer-type>org.apache.myfaces.FileUpload</renderer-type>
               <renderer-class>org.apache.myfaces.custom.fileupload.HtmlFileUploadRenderer</renderer-class>
  +        </renderer>
  +
  +        <renderer>
  +            <component-family>javax.faces.Panel</component-family>
  +            <renderer-type>org.apache.myfaces.Popup</renderer-type>
  +            <renderer-class>org.apache.myfaces.custom.popup.HtmlPopupRenderer</renderer-class>
           </renderer>
   
           <renderer>
  
  
  
  1.27      +21 -1     incubator-myfaces/conf/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/conf/web.xml,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- web.xml	13 Oct 2004 10:53:34 -0000	1.26
  +++ web.xml	16 Nov 2004 16:25:52 -0000	1.27
  @@ -131,13 +131,33 @@
           <filter-class>org.apache.myfaces.custom.fileupload.MultipartFilter</filter-class>
           <init-param>
               <param-name>maxFileSize</param-name>
  -            <param-value>10m</param-value>
  +            <param-value>100m</param-value>
               <description>Set the size limit for uploaded files.
                   Format: 10 - 10 bytes
                           10k - 10 KB
                           10m - 10 MB
  +                        1g - 1 GB
               </description>
           </init-param>
  +        <init-param>
  +            <param-name>thresholdSize</param-name>
  +            <param-value>100k</param-value>
  +            <description>Set the threshold size - files
  +                    below this limit are stored in memory, files above
  +                    this limit are stored on disk.
  +
  +                Format: 10 - 10 bytes
  +                        10k - 10 KB
  +                        10m - 10 MB
  +                        1g - 1 GB
  +            </description>
  +        </init-param>
  +<!--        <init-param>
  +            <param-name>repositoryPath</param-name>
  +            <param-value>/temp</param-value>
  +            <description>Set the path where the intermediary files will be stored.
  +            </description>
  +        </init-param>-->
       </filter>
   
   
  
  
  
  1.4       +38 -9     incubator-myfaces/src/codegen/org/apache/myfaces/codegen/component/ComponentGeneratorTask.java
  
  Index: ComponentGeneratorTask.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/codegen/org/apache/myfaces/codegen/component/ComponentGeneratorTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ComponentGeneratorTask.java	13 Oct 2004 11:50:56 -0000	1.3
  +++ ComponentGeneratorTask.java	16 Nov 2004 16:25:52 -0000	1.4
  @@ -18,6 +18,8 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.taskdefs.MatchingTask;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   import java.io.File;
   
  @@ -28,11 +30,12 @@
   public class ComponentGeneratorTask
           extends MatchingTask
   {
  -    //private static final Log log = LogFactory.getLog(ComponentInspectorTask.class);
  +    private static final Log log = LogFactory.getLog(ComponentGeneratorTask.class);
   
       private File _basedir;
       private File _destdir;
       private File _velocityLoaderPath;
  +    private String _includes;
   
       public File getBasedir()
       {
  @@ -44,6 +47,16 @@
           _basedir = basedir;
       }
   
  +    public String getIncludes()
  +    {
  +        return _includes;
  +    }
  +
  +    public void setIncludes(String includes)
  +    {
  +        _includes = includes;
  +    }
  +
       public File getDestdir()
       {
           return _destdir;
  @@ -66,16 +79,32 @@
   
       public void execute() throws BuildException
       {
  -        DirectoryScanner ds = getDirectoryScanner(_basedir);
  -        ds.scan();
  +        log.info("Executing ComponentGeneratorTask: ");
  +        log.info("baseDir : "+_basedir);
  +        log.info("destDir : "+_destdir);
  +        log.info("velocityLoaderPath : "+_velocityLoaderPath);
   
           ComponentGenerator generator = new ComponentGenerator(_destdir, _velocityLoaderPath);
   
  -        String[] files = ds.getIncludedFiles();
  -        for (int i = 0; i < files.length; i++)
  +        if(_includes==null)
  +        {
  +            DirectoryScanner ds = getDirectoryScanner(_basedir);
  +            ds.scan();
  +
  +            String[] files = ds.getIncludedFiles();
  +            for (int i = 0; i < files.length; i++)
  +            {
  +                String xmlFileName = files[i];
  +                log.info("on xmlFileName : "+files[i]);
  +                generator.generate(new File(_basedir, xmlFileName));
  +            }
  +        }
  +        else
           {
  -            String xmlFileName = files[i];
  -            generator.generate(new File(_basedir, xmlFileName));
  +            //_includes = _includes.replace('/','\\');
  +
  +            log.info("on xmlFileName : "+_basedir+"/"+_includes);
  +            generator.generate(new File(_basedir, _includes));
           }
       }
   
  
  
  
  1.5       +35 -14    incubator-myfaces/src/components/org/apache/myfaces/custom/fileupload/MultipartFilter.java
  
  Index: MultipartFilter.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/fileupload/MultipartFilter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MultipartFilter.java	13 Oct 2004 11:50:57 -0000	1.4
  +++ MultipartFilter.java	16 Nov 2004 16:25:52 -0000	1.5
  @@ -15,6 +15,8 @@
    */
   package org.apache.myfaces.custom.fileupload;
   
  +import org.apache.commons.fileupload.FileUpload;
  +
   import java.io.IOException;
   
   import javax.servlet.*;
  @@ -29,7 +31,9 @@
       implements Filter
   {
   
  -    private int maxFileSize = 10 * 1024 * 1024; // 10 MB
  +    private int maxFileSize = 100 * 1024 * 1024; // 10 MB
  +    private int thresholdSize = 1 * 1024 * 1024; // 1 MB
  +    private String repositoryPath = null; //standard temp directory
   
   
       /**
  @@ -37,15 +41,33 @@
        */
       public void init(FilterConfig filterConfig)
       {
  +
           String param = filterConfig.getInitParameter("maxFileSize");
   
  +        maxFileSize = resolveSize(param, maxFileSize);
  +
  +        param = filterConfig.getInitParameter("thresholdSize");
  +
  +        thresholdSize = resolveSize(param, thresholdSize);
  +
  +        repositoryPath = filterConfig.getInitParameter("repositoryPath");
  +    }
  +
  +    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("m"))
  +            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);
  @@ -55,8 +77,9 @@
                   number = param.substring(0, param.length() - 1);
               }
   
  -            maxFileSize = Integer.parseInt(number) * factor;
  +            numberParam = Integer.parseInt(number) * factor;
           }
  +        return numberParam;
       }
   
   
  @@ -72,17 +95,15 @@
           }
   
           HttpServletRequest httpRequest = (HttpServletRequest) request;
  -        String type = httpRequest.getHeader("Content-Type");
   
           // Process only multipart/form-data requests
  -        if (type != null)
  -            if (type.startsWith("multipart/form-data"))
  -            {
  -                HttpServletResponse httpResponse = (HttpServletResponse) response;
  -                MultipartRequestWrapper requestWrapper = new MultipartRequestWrapper(httpRequest,
maxFileSize);
  -                chain.doFilter(requestWrapper, response);
  -                return;
  -            }
  +        if(FileUpload.isMultipartContent(httpRequest))
  +        {
  +            MultipartRequestWrapper requestWrapper = new MultipartRequestWrapper(
  +                    httpRequest, maxFileSize,thresholdSize,repositoryPath);
  +            chain.doFilter(requestWrapper, response);
  +            return;
  +        }
   
           // Standard request
           chain.doFilter(request, response);
  
  
  
  1.8       +31 -7     incubator-myfaces/src/components/org/apache/myfaces/custom/fileupload/MultipartRequestWrapper.java
  
  Index: MultipartRequestWrapper.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/fileupload/MultipartRequestWrapper.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MultipartRequestWrapper.java	13 Oct 2004 11:50:57 -0000	1.7
  +++ MultipartRequestWrapper.java	16 Nov 2004 16:25:52 -0000	1.8
  @@ -16,6 +16,8 @@
   package org.apache.myfaces.custom.fileupload;
   
   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;
  @@ -26,6 +28,9 @@
    * @author Sylvain Vieujot (latest modification by $Author$)
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.8  2004/11/16 16:25:52  mmarinschek
  + * new popup - component; not yet finished
  + *
    * Revision 1.7  2004/10/13 11:50:57  matze
    * renamed packages to org.apache
    *
  @@ -42,22 +47,35 @@
   public class MultipartRequestWrapper
   		extends HttpServletRequestWrapper
   {
  +    private static Log log = LogFactory.getLog(MultipartRequestWrapper.class);
  +
   	HttpServletRequest request = null;
   	HashMap parametersMap = null;
  -	FileUpload fileUpload = null;
  +	DiskFileUpload fileUpload = null;
   	HashMap fileItems = null;
   	int maxSize;
  +    int thresholdSize;
  +    String repositoryPath;
   
  -	public MultipartRequestWrapper(HttpServletRequest request, int maxSize){
  +    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 FileUpload();
  -		fileUpload.setSizeMax(maxSize);
  +		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);
  @@ -67,10 +85,16 @@
   		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){
  -			// TODO : Log !
  +			log.error("Exception while uploading file.", fue);
   			requestParameters = Collections.EMPTY_LIST;
   		}
   
  
  
  
  1.1                  incubator-myfaces/src/components/org/apache/myfaces/custom/popup/HtmlPopup.java
  
  Index: HtmlPopup.java
  ===================================================================
  /*
   * 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.custom.popup;
  
  import javax.faces.component.UIComponentBase;
  import javax.faces.component.UIComponent;
  
  /**
   * @author Martin Marinschek (latest modification by $Author: mmarinschek $)
   * @version $Revision: 1.1 $ $Date: 2004/11/16 16:25:52 $
   */
  public class HtmlPopup
          extends UIComponentBase
  {
      //private static final Log log = LogFactory.getLog(HtmlPopup.class);
  
      private static final String POPUP_FACET_NAME            = "popup";
  
      public void setPopup(UIComponent popup)
      {
          getFacets().put(POPUP_FACET_NAME, popup);
      }
  
      public UIComponent getPopup()
      {
          return (UIComponent)getFacets().get(POPUP_FACET_NAME);
      }
  
      public boolean getRendersChildren()
      {
          return true;
      }
  
  
      //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
  
      public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPopup";
      public static final String COMPONENT_FAMILY = "javax.faces.Panel";
      private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Popup";
  
  
      public HtmlPopup()
      {
          setRendererType(DEFAULT_RENDERER_TYPE);
      }
  
      public String getFamily()
      {
          return COMPONENT_FAMILY;
      }
  
  
  
      //------------------ GENERATED CODE END ---------------------------------------
  }
  
  
  
  1.1                  incubator-myfaces/src/components/org/apache/myfaces/custom/popup/HtmlPopup.xml
  
  Index: HtmlPopup.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  <!DOCTYPE component PUBLIC
    "-//MyFaces//DTD MyFaces component def 1.0//EN"
    "http://myfaces.apache.org/dtd/Component.dtd">
  <component>
      <component-class>org.apache.myfaces.custom.popup.HtmlPopup</component-class>
      <base-class>javax.faces.component.UIComponentBase</base-class>
      <component-type>org.apache.myfaces.HtmlPopup</component-type>
      <component-family>javax.faces.Panel</component-family>
      <renderer-type>org.apache.myfaces.Popup</renderer-type>
  </component>
  
  
  
  1.1                  incubator-myfaces/src/components/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java
  
  Index: HtmlPopupRenderer.java
  ===================================================================
  /*
   * 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.custom.popup;
  
  import org.apache.myfaces.renderkit.RendererUtils;
  import org.apache.myfaces.renderkit.html.HtmlRenderer;
  import org.apache.myfaces.renderkit.html.HTML;
  import org.apache.commons.beanutils.BeanUtils;
  
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.context.ResponseWriter;
  import java.io.IOException;
  import java.util.List;
  import java.lang.reflect.InvocationTargetException;
  
  /**
   * @author Martin Marinschek (latest modification by $Author: mmarinschek $)
   * @version $Revision: 1.1 $ $Date: 2004/11/16 16:25:52 $
   * $Log: HtmlPopupRenderer.java,v $
   * Revision 1.1  2004/11/16 16:25:52  mmarinschek
   * new popup - component; not yet finished
   *
   *
   */
  public class HtmlPopupRenderer
      extends HtmlRenderer
  {
      public static final String RENDERER_TYPE = "org.apache.myfaces.Popup";
      //private static final Log log = LogFactory.getLog(HtmlListRenderer.class);
  
      public boolean getRendersChildren()
      {
          return true;
      }
  
      public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException
      {
      }
  
      public void encodeChildren(FacesContext facesContext, UIComponent component) throws
IOException
      {
  
      }
  
  
      public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
      {
          RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlPopup.class);
  
          HtmlPopup popup = (HtmlPopup) uiComponent;
  
          UIComponent popupFacet = popup.getPopup();
  
          String popupId = writePopupScript(
                  facesContext, popup.getClientId(facesContext));
  
          writeMouseOverAndOutAttribs(popupId, popupFacet.getChildren());
  
          writeMouseOverAttribs(popupId, uiComponent.getChildren());
  
          RendererUtils.renderChildren(facesContext, uiComponent);
  
          ResponseWriter writer = facesContext.getResponseWriter();
  
          writer.startElement(HTML.DIV_ELEM, uiComponent);
          writer.writeAttribute(HTML.STYLE_ATTR,"position:absolute;display:none;background:#CCCCCC;",null);
          writer.writeAttribute(HTML.ID_ATTR, popup.getClientId(facesContext),null);
          RendererUtils.renderChildren(facesContext, popupFacet);
          writer.endElement(HTML.DIV_ELEM);
      }
  
      private void writeMouseOverAttribs(String popupId, List children)
      {
          for (int i = 0; i < children.size(); i++)
          {
              UIComponent uiComponent = (UIComponent) children.get(i);
  
              callMethod(uiComponent,"onmouseover",new String(popupId+".display(event);"));
  
              writeMouseOverAttribs(popupId, uiComponent.getChildren());
          }
      }
  
      private String writePopupScript(FacesContext context, String clientId)
          throws IOException
      {
          ResponseWriter writer = context.getResponseWriter();
  
          String popupId = (clientId+"Popup").replace(':','_').replaceAll("_",
                  "popupIdSeparator");
  
          writer.startElement(HTML.SCRIPT_ELEM,null);
          writer.writeAttribute(HTML.SCRIPT_LANGUAGE_ATTR,HTML.SCRIPT_LANGUAGE_JAVASCRIPT,null);
          writer.writeText("var "+popupId+"=new orgApacheMyfacesPopup('"+clientId+"');",null);
          writer.endElement(HTML.SCRIPT_ELEM);
  
          return popupId;
      }
  
      private void writeMouseOverAndOutAttribs(String popupId, List children)
      {
          for (int i = 0; i < children.size(); i++)
          {
              UIComponent uiComponent = (UIComponent) children.get(i);
  
              callMethod(uiComponent,"onmouseover",new String(popupId+".redisplay();"));
              callMethod(uiComponent,"onmouseout",new String(popupId+".hide();"));
  
              writeMouseOverAndOutAttribs(popupId, uiComponent.getChildren());
          }
      }
  
      private void callMethod(UIComponent uiComponent, String propName, String value)
      {
          uiComponent.getAttributes().put(propName, value);
  
          try
          {
              BeanUtils.setProperty(uiComponent,propName,value);
          }
          catch (Throwable th)
          {
          }
      }
  }
  
  
  
  1.1                  incubator-myfaces/src/components/org/apache/myfaces/custom/popup/HtmlPopupTag.java
  
  Index: HtmlPopupTag.java
  ===================================================================
  /*
   * Copyright (c) 2004 Your Corporation. All Rights Reserved.
   */
  package org.apache.myfaces.custom.popup;
  
  import org.apache.myfaces.component.UserRoleAware;
  import org.apache.myfaces.taglib.UIComponentTagBase;
  import org.apache.myfaces.taglib.html.HtmlComponentTagBase;
  import org.apache.myfaces.custom.datascroller.HtmlDataScroller;
  import org.apache.myfaces.custom.datascroller.HtmlDataScrollerRenderer;
  
  import javax.faces.component.UIComponent;
  
  /**
   * @author Martin Marinschek (latest modification by $Author: mmarinschek $)
   * @version $Revision: 1.1 $ $Date: 2004/11/16 16:25:52 $
   * $Log: HtmlPopupTag.java,v $
   * Revision 1.1  2004/11/16 16:25:52  mmarinschek
   * new popup - component; not yet finished
   *
   *
   */
  public class HtmlPopupTag
          extends HtmlComponentTagBase
  {
      //private static final Log log = LogFactory.getLog(HtmlDataScrollerTag.class);
  
      // UIComponent attributes --> already implemented in UIComponentTagBase
  
      // HTML universal attributes --> already implemented in HtmlComponentTagBase
  
      // HTML event handler attributes --> already implemented in HtmlComponentTagBase
  
      // User Role support
      private String _enabledOnUserRole;
      private String _visibleOnUserRole;
  
      public String getComponentType()
      {
          return HtmlPopup.COMPONENT_TYPE;
      }
  
      public String getRendererType()
      {
          return HtmlPopupRenderer.RENDERER_TYPE;
      }
  
      protected void setProperties(UIComponent component)
      {
          super.setProperties(component);
  
          setStringProperty(component, UserRoleAware.ENABLED_ON_USER_ROLE_ATTR, _enabledOnUserRole);
          setStringProperty(component, UserRoleAware.VISIBLE_ON_USER_ROLE_ATTR, _visibleOnUserRole);
      }
  
      // userrole attributes
      public void setEnabledOnUserRole(String enabledOnUserRole)
      {
          _enabledOnUserRole = enabledOnUserRole;
      }
  
      public void setVisibleOnUserRole(String visibleOnUserRole)
      {
          _visibleOnUserRole = visibleOnUserRole;
      }
  }
  
  
  
  1.1                  incubator-myfaces/src/components_resource/jspopup/JSPopup.js
  
  Index: JSPopup.js
  ===================================================================
  /*
   * 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.
   */
  
  function orgApacheMyfacesPopup(popupId)
  {
      this.popupId = popupId;
      this.display = orgApacheMyfacesPopupDisplay;
      this.hide = orgApacheMyfacesPopupHide;
      this.redisplay=orgApacheMyfacesPopupRedisplay;
  }
  
  function orgApacheMyfacesPopupDisplay(ev)
  {
      var elem;
      var x;
      var y;
  
      if(document.all)
      {
          elem = window.event.srcElement;
          x=window.event.x;
          y=window.event.y;
      }
      else
      {
          elem = ev.target;
          x=ev.pageX;
          y=ev.pageY;
      }
  
      x-=5;
      y-=5;
  
      var popupElem = document.getElementById(this.popupId);
  
      if(popupElem.style.display!="block")
      {
          popupElem.style.display="block";
          popupElem.style.left=""+x+"px";
          popupElem.style.top=""+y+"px";
      }
  }
  
  function orgApacheMyfacesPopupHide()
  {
      var popupElem = document.getElementById(this.popupId);
      popupElem.style.display="none";
  }
  
  function orgApacheMyfacesPopupRedisplay()
  {
      var popupElem = document.getElementById(this.popupId);
      popupElem.style.display="block";
  }
  
  
  1.123     +14 -0     incubator-myfaces/tlds/myfaces_ext.tld
  
  Index: myfaces_ext.tld
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/tlds/myfaces_ext.tld,v
  retrieving revision 1.122
  retrieving revision 1.123
  diff -u -r1.122 -r1.123
  --- myfaces_ext.tld	8 Nov 2004 20:43:15 -0000	1.122
  +++ myfaces_ext.tld	16 Nov 2004 16:25:53 -0000	1.123
  @@ -1377,6 +1377,20 @@
           </attribute>
       </tag>
   
  +    <!-- popup -->
  +    <tag>
  +        <name>popup</name>
  +        <tag-class>org.apache.myfaces.custom.popup.HtmlPopupTag</tag-class>
  +        <body-content>JSP</body-content>
  +        <description>
  +            Renders a popup which displays on a mouse event.
  +        </description>
  +        &ui_panel_attributes;
  +        &html_universal_attributes;
  +        &html_event_handler_attributes;
  +        &user_role_attributes;
  +     </tag>
  +
   
   
   <!--     Custom non-component tags     -->
  
  
  
  1.3       +1 -0      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages.properties
  
  Index: example_messages.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- example_messages.properties	8 Nov 2004 20:46:03 -0000	1.2
  +++ example_messages.properties	16 Nov 2004 16:25:53 -0000	1.3
  @@ -20,6 +20,7 @@
   nav_FileUpload      = File upload
   nav_TabbedPane      = Tabbed Pane
   nav_Calendar        = Calendar
  +nav_Popup           = Popup
   nav_dataList        = Dynamic Lists
   nav_tree            = Tree
   nav_Validate		= Validations
  
  
  
  1.2       +1 -0      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_de.properties
  
  Index: example_messages_de.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_de.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- example_messages_de.properties	20 Oct 2004 07:46:38 -0000	1.1
  +++ example_messages_de.properties	16 Nov 2004 16:25:53 -0000	1.2
  @@ -19,6 +19,7 @@
   nav_FileUpload      = Datei hochladen
   nav_TabbedPane      = Karteireiter
   nav_Calendar        = Kalender
  +nav_Popup           = Popup
   nav_dataList        = Dynamische Listen
   nav_tree            = Baum
   nav_Validate		= Validierungen
  
  
  
  1.2       +1 -0      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_fr.properties
  
  Index: example_messages_fr.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_fr.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- example_messages_fr.properties	20 Oct 2004 07:46:38 -0000	1.1
  +++ example_messages_fr.properties	16 Nov 2004 16:25:53 -0000	1.2
  @@ -19,6 +19,7 @@
   nav_FileUpload      = Upload de fichier
   nav_TabbedPane      = Panneau  onglets
   nav_Calendar        = Calendrier
  +nav_Popup           = Popup
   nav_dataList        = Listes dynamiques
   nav_tree            = Arbre
   nav_Validate		= Validations
  
  
  
  1.2       +1 -0      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_ja.properties
  
  Index: example_messages_ja.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_ja.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- example_messages_ja.properties	20 Oct 2004 07:46:38 -0000	1.1
  +++ example_messages_ja.properties	16 Nov 2004 16:25:53 -0000	1.2
  @@ -19,6 +19,7 @@
   nav_FileUpload      = \u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9
   nav_TabbedPane      = \u30bf\u30d6\u30d1\u30cd\u30eb
   nav_Calendar        = \u30ab\u30ec\u30f3\u30c0\u30fc
  +nav_Popup           = Popup
   nav_dataList        = \u30c0\u30a4\u30ca\u30df\u30c3\u30af\u30ea\u30b9\u30c8
   nav_tree            =\u30c4\u30ea\u30fc
   nav_Validate		= \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3
  
  
  
  1.33      +6 -1      incubator-myfaces/webapps/examples/web/WEB-INF/examples-config.xml
  
  Index: examples-config.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/WEB-INF/examples-config.xml,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- examples-config.xml	14 Nov 2004 15:06:36 -0000	1.32
  +++ examples-config.xml	16 Nov 2004 16:25:53 -0000	1.33
  @@ -247,7 +247,12 @@
               <from-outcome>go_calendar</from-outcome>
               <to-view-id>/calendar.jsp</to-view-id>
           </navigation-case>
  -        
  +
  +        <navigation-case>
  +            <from-outcome>go_popup</from-outcome>
  +            <to-view-id>/popup.jsp</to-view-id>
  +        </navigation-case>
  +
           <navigation-case>
               <from-outcome>go_date</from-outcome>
               <to-view-id>/date.jsp</to-view-id>
  
  
  
  1.6       +4 -0      incubator-myfaces/webapps/examples/web/inc/head.inc
  
  Index: head.inc
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/inc/head.inc,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- head.inc	27 Jul 2004 06:28:33 -0000	1.5
  +++ head.inc	16 Nov 2004 16:25:53 -0000	1.6
  @@ -18,4 +18,8 @@
     <script language="JavaScript" src="jscalendar/popcalendar.js" type="text/javascript"></script>
     <link rel="stylesheet" href="jscalendar/jscalendar-WH/theme.css" type="text/css">
     <link rel="stylesheet" href="jscalendar/jscalendar-DB/theme.css" type="text/css">
  +
  +  <!-- JSPopup -->
  +  <script language="JavaScript" src="jspopup/JSPopup.js" type="text/javascript"></script>
  +
   </head>
  
  
  
  1.40      +1 -0      incubator-myfaces/webapps/examples/web/inc/navigation.jsp
  
  Index: navigation.jsp
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/inc/navigation.jsp,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- navigation.jsp	8 Nov 2004 20:46:03 -0000	1.39
  +++ navigation.jsp	16 Nov 2004 16:25:53 -0000	1.40
  @@ -20,6 +20,7 @@
               <x:commandNavigation id="nav_2_4_5" value="#{example_messages['nav_FileUpload']}"
action="go_fileupload" />
               <x:commandNavigation id="nav_2_4_6" value="#{example_messages['nav_TabbedPane']}"
action="go_tabbedPane" />
               <x:commandNavigation id="nav_2_4_7" value="#{example_messages['nav_Calendar']}"
action="go_calendar" />
  +            <x:commandNavigation id="nav_2_4_71" value="#{example_messages['nav_Popup']}"
action="go_popup" />
               <x:commandNavigation id="nav_2_4_8" value="#{example_messages['nav_Date']}"
action="go_date" />
               <x:commandNavigation id="nav_2_4_9" value="#{example_messages['nav_dataList']}"
action="go_dataList" />
               <x:commandNavigation id="nav_2_4_10" value="#{example_messages['nav_tree']}"
action="go_tree" />
  
  
  
  1.37      +1 -0      incubator-myfaces/webapps/examples/web/inc/page_header.jsp
  
  Index: page_header.jsp
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/inc/page_header.jsp,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- page_header.jsp	29 Oct 2004 16:03:53 -0000	1.36
  +++ page_header.jsp	16 Nov 2004 16:25:53 -0000	1.37
  @@ -32,6 +32,7 @@
                   <x:navigationMenuItem id="nav_2_4_4" itemLabel="#{example_messages['nav_FileUpload']}"
action="go_fileupload" icon="images/myfaces.gif" />
                   <x:navigationMenuItem id="nav_2_4_5" itemLabel="#{example_messages['nav_TabbedPane']}"
action="go_tabbedPane" icon="images/myfaces.gif" />
                   <x:navigationMenuItem id="nav_2_4_6" itemLabel="#{example_messages['nav_Calendar']}"
action="go_calendar" icon="images/myfaces.gif" split="true" />
  +                <x:navigationMenuItem id="nav_2_4_6" itemLabel="#{example_messages['nav_Popup']}"
action="go_popup" icon="images/myfaces.gif" split="true" />                
                   <x:navigationMenuItem id="nav_2_4_7" itemLabel="#{example_messages['nav_dataList']}"
action="go_dataList" icon="images/myfaces.gif" />
                   <x:navigationMenuItem id="nav_2_4_8" itemLabel="#{example_messages['nav_tree']}"
action="go_tree" icon="images/myfaces.gif" />
                   <x:navigationMenuItem id="nav_2_4_9" itemLabel="#{example_messages['nav_rssTicker']}"
action="go_rssticker" icon="images/myfaces.gif" />
  
  
  
  1.6       +1 -0      incubator-myfaces/webapps/examples/web/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/.cvsignore,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- .cvsignore	28 Jul 2004 07:06:59 -0000	1.5
  +++ .cvsignore	16 Nov 2004 16:25:53 -0000	1.6
  @@ -2,3 +2,4 @@
   B.inc
   jscookmenu
   jscalendar
  +jspopup
  
  
  
  1.23      +1 -1      incubator-myfaces/webapps/examples/web/sample2.jsp
  
  Index: sample2.jsp
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/sample2.jsp,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- sample2.jsp	1 Nov 2004 23:04:26 -0000	1.22
  +++ sample2.jsp	16 Nov 2004 16:25:53 -0000	1.23
  @@ -1,7 +1,7 @@
   <%@ page session="false" contentType="text/html;charset=utf-8"%>
   <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
   <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  -<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
  +<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x" %>
   <html>
   
   <!--
  
  
  
  1.1                  incubator-myfaces/webapps/examples/web/popup.jsp
  
  Index: popup.jsp
  ===================================================================
  <%@ page import="java.math.BigDecimal,
                   java.util.Date"%>
  <%@ page session="false" contentType="text/html;charset=utf-8"%>
  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
  <%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
  <html>
  
  <%@include file="inc/head.inc" %>
  
  <!--
  /*
   * 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.
   */
  //-->
  
  <body>
  
  <f:view>
  
      <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
  
      <x:panelLayout id="page" layout="#{globalOptions.pageLayout}"
              styleClass="pageLayout"
              headerClass="pageHeader"
              navigationClass="pageNavigation"
              bodyClass="pageBody"
              footerClass="pageFooter" >
  
          <f:facet name="header">
              <f:subview id="header">
                  <jsp:include page="inc/page_header.jsp" />
              </f:subview>
          </f:facet>
  
          <f:facet name="navigation">
              <f:subview id="menu" >
                  <jsp:include page="inc/navigation.jsp" />
              </f:subview>
          </f:facet>
  
          <f:facet name="body">
  
              <h:panelGroup id="body">
                      
                  <x:popup>
                      <h:outputText value="text"/>
                      <f:facet name="popup">
                          <h:panelGroup>
                              <h:outputText value="Popup Text"/>
                              <h:outputLink value="http://www.myfaces.org" >
                                  <h:outputText value="MyFaces Homepage"/>
                              </h:outputLink>
                          </h:panelGroup>
                      </f:facet>
                  </x:popup>
  
              </h:panelGroup>
          </f:facet>
  
          <%@include file="inc/page_footer.jsp" %>
  
      </x:panelLayout>
  
  </f:view>
  
  </body>
  
  </html>
  
  
  

Mime
View raw message