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/portals-bridges/frameworks/webapp/WEB-INF bridges-frameworks.tld
Date Fri, 05 Nov 2004 03:56:53 GMT
taylor      2004/11/04 19:56:53

  Modified:    portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks
                        GenericFrameworkPortlet.java Forwarder.java
  Added:       portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks
                        ForwardTag.java
               portals-bridges/frameworks/webapp/WEB-INF
                        bridges-frameworks.tld
  Log:
  Forward tag for JSPs, examples:
  
  <a href="<bf:forward view='sixties-view'/>">Flashback</a>
  <a href="<bf:forward forward='next-view' action='success'/>">Goodone</a>
  <a href="<bf:forward forward='next-view' action='failure'/>">Badone</a>
  <a href="<bf:forward view='help-page-2,mode:help' />">Goodone</a>
  <a href="<bf:forward forward='next-view' />">Goodone</a>
  <a href="<bf:forward view='homesweethome,mode:view,state:maximized' />">GoHomeMaxed</a>
  
  Revision  Changes    Path
  1.4       +2 -1      jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks/GenericFrameworkPortlet.java
  
  Index: GenericFrameworkPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks/GenericFrameworkPortlet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GenericFrameworkPortlet.java	5 Nov 2004 02:55:18 -0000	1.3
  +++ GenericFrameworkPortlet.java	5 Nov 2004 03:56:52 -0000	1.4
  @@ -467,7 +467,8 @@
           }
   
           putRequestVariable(request, FrameworkConstants.FORWARD_TOOL, new Forwarder(model,
request, response));
  -
  +        request.setAttribute("model", model);
  +        
           PortletContext context = getPortletContext();
           PortletRequestDispatcher rd = context.getRequestDispatcher(template);
           rd.include(request, response);
  
  
  
  1.4       +6 -1      jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks/Forwarder.java
  
  Index: Forwarder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks/Forwarder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Forwarder.java	4 Nov 2004 22:44:03 -0000	1.3
  +++ Forwarder.java	5 Nov 2004 03:56:52 -0000	1.4
  @@ -49,6 +49,11 @@
           this.response = response;
       }
       
  +    public String toString()
  +    {
  +        return response.createRenderURL().toString();        
  +    }
  +    
       private Forwarder()
       {        
       }
  
  
  
  1.1                  jakarta-jetspeed-2/portals-bridges/frameworks/src/java/org/apache/portals/bridges/frameworks/ForwardTag.java
  
  Index: ForwardTag.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.portals.bridges.frameworks;
  
  import java.io.IOException;
  
  import javax.portlet.RenderRequest;
  import javax.portlet.RenderResponse;
  import javax.servlet.jsp.JspWriter;
  import javax.servlet.jsp.tagext.TagSupport;
  
  import org.apache.portals.bridges.frameworks.model.PortletApplicationModel;
  
  
  /**
   * ForwardTag
   * 
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: ForwardTag.java,v 1.1 2004/11/05 03:56:52 taylor Exp $
   */
  public class ForwardTag extends TagSupport
  {
      private String view = null;
      private String action = null;
      private String forward = null;
      
      public int doStartTag()
      {
          String content;
          try
          {
              RenderRequest request = (RenderRequest)
                  pageContext.getRequest().getAttribute("javax.portlet.request");
              RenderResponse response = (RenderResponse) 
                  pageContext.getRequest().getAttribute("javax.portlet.response");
              
              if (request == null || response == null)
              {
                  JspWriter out = pageContext.getOut();
                  out.print("request response not found");
                  return SKIP_BODY;
              }
              PortletApplicationModel model = (PortletApplicationModel)request.getAttribute("model");
              if (model == null)
              {
                  JspWriter out = pageContext.getOut();
                  out.print("model not found");
                  return SKIP_BODY;
              }
                                                  
              Forwarder forwarder = new Forwarder(model, request, response);
              if (view != null)
              {
                  content = forwarder.getView(view).toString();
              }
              else if (forward != null)
              {
                  if (action != null)
                  {
                      content = forwarder.getLink(forward, action).toString();
                  }
                  else
                  {
                      content = forwarder.getLink(forward).toString();                   

                  }
              }
              else
              {
                  content = forwarder.toString();
              }
              JspWriter out = pageContext.getOut();
              out.print(content);            
          }
          catch (IOException e)
          {
              System.err.println("Error printing tag: " + e);
          }
          return SKIP_BODY;
      }
      
      
      /**
       * @return Returns the action.
       */
      public String getAction()
      {
          return action;
      }
      /**
       * @param action The action to set.
       */
      public void setAction(String action)
      {
          this.action = action;
      }
      /**
       * @return Returns the view.
       */
      public String getView()
      {
          return view;
      }
      /**
       * @param view The view to set.
       */
      public void setView(String view)
      {
          this.view = view;
      }
      /**
       * @return Returns the forward.
       */
      public String getForward()
      {
          return forward;
      }
      /**
       * @param forward The forward to set.
       */
      public void setForward(String forward)
      {
          this.forward = forward;
      }
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portals-bridges/frameworks/webapp/WEB-INF/bridges-frameworks.tld
  
  Index: bridges-frameworks.tld
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
           "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
  <!-- 
  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.
  -->
  
  
  <taglib>
  
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>Tags for Bridges Frameworks</short-name>
    
    <tag>
  
      <name>forward</name>
      <tag-class>org.apache.portals.bridges.frameworks.ForwardTag</tag-class>
      <body-content>empty</body-content>
      <description>
        Renders a forward link tag
      </description>
  
      <attribute>
        <name>view</name>
        <required>false</required>
        <description>
         TODO
        </description>
      </attribute>
  
      <attribute>
        <name>action</name>
        <required>false</required>
        <description>
         TODO
        </description>
      </attribute>
  
    </tag>
  
  </taglib>
  
  

---------------------------------------------------------------------
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