portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/web-content .project .classpath project.xml
Date Fri, 12 Nov 2004 06:30:40 GMT
taylor      2004/11/11 22:30:40

  Modified:    components/web-content project.xml
  Added:       components/web-content/src/java/org/apache/jetspeed/portlet
                        IFrameGenericPortlet.java
               components/web-content .project .classpath
  Log:
  rewrite of IFramePortlet to meet external requirements
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed-2/components/web-content/src/java/org/apache/jetspeed/portlet/IFrameGenericPortlet.java
  
  Index: IFrameGenericPortlet.java
  ===================================================================
  /*
   * Copyright 2000-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.jetspeed.portlet;
  
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import javax.portlet.ActionRequest;
  import javax.portlet.ActionResponse;
  import javax.portlet.PortletConfig;
  import javax.portlet.PortletException;
  import javax.portlet.PortletMode;
  import javax.portlet.PortletPreferences;
  import javax.portlet.RenderRequest;
  import javax.portlet.RenderResponse;
  import javax.portlet.WindowState;
  
  import org.apache.portals.bridges.velocity.GenericVelocityPortlet;
  import org.apache.velocity.context.Context;
  
  import org.apache.portals.bridges.util.PreferencesHelper;
  
  
  /**
   * IFrameGenericPortlet
   * 
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
   * @version $Id: IFrameGenericPortlet.java,v 1.1 2004/11/12 06:30:40 taylor Exp $
   */
  public class IFrameGenericPortlet extends GenericVelocityPortlet
  {
      private Map attributes = new HashMap();
  
      private Map maxAttributes = new HashMap();
  
      public void init(PortletConfig config) throws PortletException
      {
          super.init(config);
          attributes.put("SRC", "http://www.apache.org");
          attributes.put("ALIGN", "BOTTOM");
          attributes.put("CLASS", "");
          attributes.put("FRAMEBORDER", "0");
          attributes.put("ID", "");
          attributes.put("MARGINHEIGHT", "0");
          attributes.put("MARGINWIDTH", "0");
          attributes.put("NAME", "");
  
          attributes.put("HEIGHT", "100%");
          attributes.put("WIDTH", "100%");
          attributes.put("SCROLLING", "NO");
          attributes.put("STYLE", "");
  
          maxAttributes.put("HEIGHT", "800");
          maxAttributes.put("WIDTH", "100%");
          maxAttributes.put("SCROLLING", "AUTO");
          maxAttributes.put("STYLE", "");
      }
  
      private String getAttributePreference(PortletPreferences prefs, String attribute)
      {
          return this.getMappedAttributePreference(prefs, attribute, attributes);
      }
  
      private String getMaxAttributePreference(PortletPreferences prefs, String attribute)
      {
          return this.getMappedAttributePreference(prefs, "MAX-" + attribute, maxAttributes);
      }
  
      private String getMappedAttributePreference(PortletPreferences prefs, String attribute,
Map map)
      {
          return prefs.getValue(attribute, (String) map.get(attribute));
      }
  
      private void appendAttribute(PortletPreferences prefs, StringBuffer content, String
attribute, Map map)
      {
          String value;
          
          if (map == maxAttributes)
              value = getMaxAttributePreference(prefs, attribute);
          else
              value = getAttributePreference(prefs, attribute);
          
          System.out.println("ATT = " + attribute + "VALUE = " + value);
          if (value == null || value == "") { return; }
          content.append(" ").append(attribute).append("=\"").append(value).append("\"");
      }
  
      private void appendAttribute(PortletPreferences prefs, StringBuffer content, String
attribute)
      {
          appendAttribute(prefs, content, attribute, attributes);
      }
  
      private void appendMaxAttribute(PortletPreferences prefs, StringBuffer content, String
attribute)
      {
          appendAttribute(prefs, content, attribute, maxAttributes);
      }
  
      public void doView(RenderRequest request, RenderResponse response) throws PortletException,
IOException
      {
          doIFrame(request, response);
      }
  
      public void doEdit(RenderRequest request, RenderResponse response) throws PortletException,
IOException
      {
          Context context = getContext(request);
          PortletPreferences prefs = request.getPreferences();
          Iterator it = prefs.getMap().entrySet().iterator();
          context.put("prefs", it);
          super.doEdit(request, response);
      }
      
      /**
       * Render IFRAME content
       */
      protected void doIFrame(RenderRequest request, RenderResponse response) throws IOException
      {
          PortletPreferences prefs = request.getPreferences();
          // generate HTML IFRAME content
          StringBuffer content = new StringBuffer(4096);
          content.append("<IFRAME");
          appendAttribute(prefs, content, "SRC");
          appendAttribute(prefs, content, "ALIGN");
          appendAttribute(prefs, content, "CLASS");
          appendAttribute(prefs, content, "FRAMEBORDER");
          appendAttribute(prefs, content, "ID");
          appendAttribute(prefs, content, "MARGINHEIGHT");
          appendAttribute(prefs, content, "MARGINWIDTH");
          appendAttribute(prefs, content, "NAME");
          if (request.getWindowState().equals(WindowState.MAXIMIZED))
          {
              appendMaxAttribute(prefs, content, "HEIGHT");
              appendMaxAttribute(prefs, content, "WIDTH");
              appendMaxAttribute(prefs, content, "SCROLLING");
              appendMaxAttribute(prefs, content, "STYLE");
          }
          else
          {
              appendAttribute(prefs, content, "HEIGHT");
              appendAttribute(prefs, content, "WIDTH");
              appendAttribute(prefs, content, "SCROLLING");
              appendAttribute(prefs, content, "STYLE");
          }
          content.append(">");
          content.append("<P STYLE=\"textAlign:center\"><A HREF=\"").append(getAttributePreference(prefs,
"SRC")).append(
                  "\">").append(getAttributePreference(prefs, "SRC")).append("</A></P>");
          content.append("</IFRAME>");
  
          // set required content type and write HTML IFRAME content
          response.setContentType("text/html");
          response.getWriter().print(content.toString());
      }
  
      /**
       * Save the prefs
       */
      public void processAction(ActionRequest request, ActionResponse actionResponse)
      throws PortletException, IOException
      {
          PortletPreferences prefs = request.getPreferences();
          PreferencesHelper.requestParamsToPreferences(request);
          prefs.store();
          actionResponse.setPortletMode(PortletMode.VIEW);
      }
      
  }
  
  
  1.4       +33 -0     jakarta-jetspeed-2/components/web-content/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/web-content/project.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- project.xml	13 Oct 2004 20:01:45 -0000	1.3
  +++ project.xml	12 Nov 2004 06:30:40 -0000	1.4
  @@ -93,6 +93,39 @@
         <groupId>pluto</groupId>
         <version>1.0.1-rc1</version>
       </dependency>
  +
  +    <dependency>
  +      <id>velocity</id>
  +      <version>1.4</version>
  +      <properties>
  +        <war.bundle>true</war.bundle>
  +      </properties>      
  +    </dependency>
  +    <dependency>
  +      <id>velocity-tools:velocity-tools-view</id>
  +      <version>1.1-beta1</version>
  +      <url>http://jakarta.apache.org/velocity</url>
  +      <properties>
  +        <war.bundle>true</war.bundle>
  +      </properties>      
  +    </dependency>    
  +    <dependency>
  +      <groupId>portals-bridges</groupId>
  +      <artifactId>portals-bridges-velocity</artifactId>
  +      <version>0.1</version>
  +      <properties>
  +        <war.bundle>true</war.bundle>
  +      </properties>
  +    </dependency>	
  +    <dependency>
  +      <groupId>portals-bridges</groupId>
  +      <artifactId>portals-bridges-common</artifactId>
  +      <version>0.1</version>
  +      <properties>
  +        <war.bundle>true</war.bundle>
  +      </properties>
  +    </dependency>	
  +
       <dependency>
         <!-- portlet-api.jar must be in %MAVEN_HOME%respository/portlet-api/jars -->
         <id>portlet-api</id>
  
  
  
  1.1                  jakarta-jetspeed-2/components/web-content/.project
  
  Index: .project
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <projectDescription>
    <name>jetspeed-web-content</name>
    <comment>Web content service and portlet implementations.</comment>
    <projects>
    </projects>
    <buildSpec>
      <buildCommand>
        <name>org.eclipse.jdt.core.javabuilder</name>
        <arguments>
        </arguments>
      </buildCommand>
    </buildSpec>
    <natures>
      <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
  </projectDescription>
  
  
  1.1                  jakarta-jetspeed-2/components/web-content/.classpath
  
  Index: .classpath
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <classpath>
    <classpathentry excluding="" kind="src" path="src\java">
    </classpathentry>
    <classpathentry output="target\test-classes" kind="src" path="src\test">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar">
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/cglib/jars/cglib-2.0.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/springframework/jars/spring-core-1.1.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/springframework/jars/spring-aop-1.1.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/springframework/jars/spring-context-1.1.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/springframework/jars/spring-dao-1.1.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/springframework/jars/spring-orm-1.1.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/aopalliance/jars/aopalliance-1.0.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/oro/jars/oro-2.0.7.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/jetspeed2/jars/jetspeed-commons-2.0-a1-dev.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/commons-httpclient/jars/commons-httpclient-2.0.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/commons-lang/jars/commons-lang-2.0.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.3.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/commons-beanutils/jars/commons-beanutils-1.6.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/commons-configuration/jars/commons-configuration-1.0-dev.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/log4j/jars/log4j-1.2.6.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/commons-collections/jars/commons-collections-3.0.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/commons-io/jars/commons-io-0.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/xerces/jars/xerces-2.3.0.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/xml-apis/jars/xml-apis-2.0.2.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/pluto/jars/pluto-1.0.1-rc1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/velocity/jars/velocity-1.4.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/velocity-tools/jars/velocity-tools-view-1.1-beta1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/portals-bridges/jars/portals-bridges-velocity-0.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/portals-bridges/jars/portals-bridges-common-0.1.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/portlet-api/jars/portlet-api-1.0.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/servletapi/jars/servletapi-2.3.jar">
    </classpathentry>
    <classpathentry kind="var" path="MAVEN_REPO/hsqldb/jars/hsqldb-1.7.1.jar">
    </classpathentry>
    <classpathentry kind="output" path="target\classes">
    </classpathentry>
  </classpath>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message