patrickl    01/11/20 17:10:09

  Modified:    webapps/admin/WEB-INF struts-config.xml web.xml
  Added:       webapps/admin/WEB-INF/classes/org/apache/webapp/admin
                        SetUpTreeAction.java TreeBuilder.java
  Removed:     webapps/admin/WEB-INF/classes/org/apache/webapp/admin
                        TreeControlTestListener.java
  Log:
  Enhancements to the tree renderer to make it more "pluggable"
  Submitted by: Jazmin Jonson
  
  Revision  Changes    Path
  1.8       +8 -0      jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml
  
  Index: struts-config.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- struts-config.xml 2001/11/18 17:17:08     1.7
  +++ struts-config.xml 2001/11/21 01:10:09     1.8
  @@ -65,6 +65,14 @@
       <action    path="/dumpServer"
                  type="org.apache.webapp.admin.DumpServerAction"/>
   
  +    <!-- Set up Tree datastructure -->
  +    <action    path="/setUpTree"
  +               type="org.apache.webapp.admin.SetUpTreeAction">
  +      <forward        name="SetUpTree"
  +                      path="/tree-control-test.jsp"
  +                  redirect="true"/>
  +    </action>
  +
       <!-- Log out of the application -->
       <action    path="/logOut"
                  type="org.apache.webapp.admin.LogOutAction">
  
  
  
  1.5       +0 -11     jakarta-tomcat-4.0/webapps/admin/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/web.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- web.xml   2001/11/18 21:09:12     1.4
  +++ web.xml   2001/11/21 01:10:09     1.5
  @@ -6,13 +6,6 @@
   
   <web-app>
   
  -  <!-- Session Event Listener for Tree Control Test -->
  -  <listener>
  -    <listener-class>
  -      org.apache.webapp.admin.TreeControlTestListener
  -    </listener-class>
  -  </listener>
  -
     <!-- Action Servlet Configuration -->
     <servlet>
       <servlet-name>action</servlet-name>
  @@ -48,10 +41,6 @@
       <init-param>
         <param-name>validate</param-name>
         <param-value>true</param-value>
  -    </init-param>
  -    <init-param>
  -      <param-name>treebuilders</param-name>
  -      <param-value>org.apache.webapp.admin.TomcatTreeBuilder</param-value>
       </init-param>
       <load-on-startup>2</load-on-startup>
     </servlet>
  
  
  
  1.1                  
jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SetUpTreeAction.java
  
  Index: SetUpTreeAction.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SetUpTreeAction.java,v
 1.1 2001/11/21 01:10:09 patrickl Exp $
   * $Revision: 1.1 $
   * $Date: 2001/11/21 01:10:09 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  package org.apache.webapp.admin;
  
  
  import java.io.IOException;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Locale;
  import java.util.StringTokenizer;
  import java.util.ArrayList;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  
  /**
   * Test <code>Action</code> sets up  tree control data structure
   * for tree widget
   *
   * @author Jazmin Jonson
   * @version $Revision: 1.1 $ $Date: 2001/11/21 01:10:09 $
   */
  
  public class SetUpTreeAction extends Action {
  
      public static final int INIT_PLUGIN_MAX = 10;
      public static final String TREEBUILDER_KEY = "treebuilders";
  
      // --------------------------------------------------------- Public Methods
  
      /**
       * Process the specified HTTP request, and create the corresponding HTTP
       * response (or forward to another web component that will create it).
       * Return an <code>ActionForward</code> instance describing where and how
       * control should be forwarded, or <code>null</code> if the response has
       * already been completed.
       *
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       */
      public ActionForward perform(ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
          throws IOException, ServletException {
  
          // Make the root node and tree control
  
          TreeControlNode root =
              new TreeControlNode("ROOT-NODE",
                                  null, "Root Node",
                                  "treeControlTest.do?select=ROOT-NODE",
                                  null, true);
          TreeControl control = new TreeControl(root);
          ApplicationServlet servlet = (ApplicationServlet)getServlet();
  
          // Wait for web.xml code to be hooked up
  
          String treeBuildersStr  =
              (String)servlet.getServletConfig().getInitParameter(TREEBUILDER_KEY);
  
          if(treeBuildersStr != null) {
              Class treeBuilderImpl;
              TreeBuilder treeBuilderBase;
  
              ArrayList treeBuilders = new ArrayList(INIT_PLUGIN_MAX);
              int i = 0;
              StringTokenizer st = new StringTokenizer(treeBuildersStr, ", ");
              while (st.hasMoreTokens()) {
                  treeBuilders.add(st.nextToken());
              }
  
              if(treeBuilders.size() == 0)
                  treeBuilders.add(treeBuildersStr);
  
              for(i = 0; i < treeBuilders.size(); i++) {
  
                  try{
                      treeBuilderImpl = Class.forName((String)treeBuilders.get(i));
                      treeBuilderBase =
                          (TreeBuilder)treeBuilderImpl.newInstance();
                      treeBuilderBase.buildTree(control, servlet, request);
                  }catch(Throwable t){
                      t.printStackTrace(System.out);
                  }
              }
          }
  
          HttpSession session = request.getSession();
          session.setAttribute("treeControlTest", control);
  
          return (mapping.findForward("Tree Control Test"));
  
      }
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TreeBuilder.java
  
  Index: TreeBuilder.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TreeBuilder.java,v
 1.1 2001/11/21 01:10:09 patrickl Exp $
   * $Revision: 1.1 $
   * $Date: 2001/11/21 01:10:09 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.webapp.admin;
  
  /**
   * <p> Interface for Admin Tree Controller to build plugin components
   * into the tree
   *
   * @author Jazmin Jonson
   * @version
   */
  
  import javax.servlet.http.HttpServletRequest;
  
  public interface TreeBuilder {
  
      public void buildTree(TreeControl treeControl,
                            ApplicationServlet servlet,
                            HttpServletRequest request);
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to