You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ce...@apache.org on 2002/07/11 17:35:21 UTC

cvs commit: jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dev1-1 ApplicationResources.properties

cedric      2002/07/11 08:35:21

  Added:       src/tiles-documentation/org/apache/struts/webapp/tiles/portal
                        UserPortalSettingsAction.java UserPortalAction.java
                        UserMenuSettingsAction.java UserMenuAction.java
                        PortalSettingsForm.java PortalSettings.java
                        PortalCatalog.java MenuSettingsForm.java
                        MenuSettings.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/test
                        TestTileController.java TestActionTileAction.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/skin
                        SimpleSwitchLayoutAction.java
                        LayoutSwitchAction.java LayoutSettingsForm.java
                        LayoutSettingsAction.java DefinitionCatalog.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/dynPortal
                        SetPortalPrefsAction.java RetrievePortalAction.java
                        PortalSettings.java PortalPrefsForm.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/lang
                        SelectLocaleAction.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/channel
                        SelectChannelAction.java ChannelFactorySet.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/rssChannel
                        RssChannelsAction.java Channels.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/invoice
                        InvoiceForm.java Invoice.java
                        EditInvoiceAction.java Address.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/tutorial
                        ForwardExampleAction.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/template
                        DynTemplateAction.java
               src/tiles-documentation/org/apache/struts/webapp/tiles/dev1-1
                        ApplicationResources.properties
  Log:
  Change package name of Tiles examples classes.
  org.apache.struts.example.tiles.* --> org.apache.struts.webapp.tiles.*
  The new name follows the struts naming scheme.
  
  Revision  Changes    Path
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/UserPortalSettingsAction.java
  
  Index: UserPortalSettingsAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/UserPortalSettingsAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.portal;
  
  import org.apache.struts.tiles.*;
  import org.apache.struts.tiles.actions.TilesAction;
  
  import java.io.IOException;
  import java.util.Locale;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  import org.apache.struts.util.RequestUtils;
  
  
  /**
   * Implementation of <strong>Action</strong> that populates an instance of
   * <code>SubscriptionForm</code> from the currently specified subscription.
   *
   * This action is used as controller for portal settings editor.
   * It does folowing :
   * <ul>
   * <li>Load or create user portal settings</li>
   * <li>Read web form, and set user portal setting accordingly</li>
   * <li>Prepare portal editor needed attributes</li>
   * <li></li>
   * </ul>
   *
   * @author Cedric Dumoulin
   * @version $Revision: 1.1 $ $Date: 2002/07/11 15:35:20 $
   */
  
  public final class UserPortalSettingsAction extends TilesAction {
  
  
      // --------------------------------------------------------- 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 servlet The ActionServlet making this request
       * @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( ComponentContext context,
                                   ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
                            throws IOException, ServletException
    {
    //System.out.println("Enter action UserPortalSettingsAction");
    PortalSettingsForm prefsForm = (PortalSettingsForm)form;
  
        // Get user portal settings from user context
    PortalSettings settings = UserPortalAction.getSettings( request, context);
    PortalCatalog catalog = UserPortalAction.getPortalCatalog( context, getServlet().getServletContext() );
  
    if( prefsForm.isSubmitted() )
      {  // read arrays
      //System.out.println("form submitted");
  
        // Set settings cols according to user choice
      for( int i=0;i<prefsForm.getNumCol(); i++)
        {
        settings.setListAt( i, catalog.getTiles( prefsForm.getNewCol(i)) );
        } // end loop
  
      //System.out.println( "settings : " +settings.toString() );
      prefsForm.reset();
  	  //return null; // (mapping.findForward("viewPortal"));
      }
  
        // Set lists values to be shown
      for( int i=0;i<settings.getNumCols(); i++ )
        {
        prefsForm.addCol(settings.getListAt(i) );
        prefsForm.addColLabels(catalog.getTileLabels( settings.getListAt(i)) );
        } // end loop
  
      prefsForm.setChoices(catalog.getTiles() );
      prefsForm.setChoiceLabels(catalog.getTilesLabels() );
  
      //System.out.println("Exit action UserPortalSettingsAction");
  	  return null; //(mapping.findForward("editPortal"));
      }
  
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/UserPortalAction.java
  
  Index: UserPortalAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/UserPortalAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.portal;
  
  import org.apache.struts.tiles.*;
  import org.apache.struts.tiles.actions.TilesAction;
  
  import java.io.IOException;
  import java.util.Locale;
  //import java.util.Vector;
  import java.util.List;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.ServletContext;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  import org.apache.struts.util.RequestUtils;
  
  
  /**
   * This controller load user portal settings and put them in tile context.
   * If portal settings are not defined for user, defined them based on tiles
   * attributes used as default.
   *
   * @author Cedric Dumoulin
   * @version $Revision: 1.1 $ $Date: 2002/07/11 15:35:20 $
   */
  
  public final class UserPortalAction extends TilesAction {
  
        /** Default name used to store settings in session context */
      public static String DEFAULT_USER_SETTINGS_NAME = "tiles.examples.portal.USER_PORTAL_SETTINGS";
        /** Tile attribute containing number of columns in portal */
      public static String NUMCOLS_ATTRIBUTE = "numCols";
        /** Tile attribute containing list prefix name */
      public static String LIST_ATTRIBUTE = "list";
        /** Tile attribute containing list of labels prefix name */
      public static String LIST_LABELS_ATTRIBUTE = "labels";
        /** Tile attribute containing name used to store user settings in session context */
      public static String USER_SETTINGS_NAME_ATTRIBUTE = "userSettingsName";
        /** Name used to store portal catalog in application scope */
      public static String PORTAL_CATALOG_NAME = "tiles.examples.portal.PortalCatalog";
  
      // --------------------------------------------------------- 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 servlet The ActionServlet making this request
       * @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( ComponentContext context,
                                   ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
                            throws IOException, ServletException
      {
      //System.out.println("Enter action UserPortalAction");
  
        // Get user portal list from user context
      PortalSettings settings = getSettings( request, context);
        // Set parameters for tiles
      context.putAttribute( "numCols", Integer.toString(settings.getNumCols()) );
      for( int i=0; i<settings.getNumCols(); i++ )
        context.putAttribute( "list"+i, settings.getListAt(i) );
  
      //System.out.println( "settings=" + settings );
      //System.out.println("Exit action UserPortalAction");
  	  return null;
      }
  
      /**
       * Retrieve user setting from session.
       * If settings are not found, initialized them.
       */
    public static PortalSettings getSettings( HttpServletRequest request, ComponentContext context )
    {
        // Get current session.
  	  HttpSession session = request.getSession();
        // Retrieve user context id used to store settings
      String userSettingsId = (String)context.getAttribute( USER_SETTINGS_NAME_ATTRIBUTE );
      if( userSettingsId == null )
        userSettingsId = DEFAULT_USER_SETTINGS_NAME;
  
        // Get user portal list from user context
      PortalSettings settings = (PortalSettings)session.getAttribute( userSettingsId );
  
      if( settings == null )
        { // List doesn't exist, create it and initialize it from Tiles parameters
        settings = new PortalSettings();
        settings.setNumCols( (String)context.getAttribute( NUMCOLS_ATTRIBUTE ) );
        for( int i=0; i<settings.getNumCols(); i++ )
          {
          List tiles = (List)context.getAttribute( ((String)LIST_ATTRIBUTE+i) );
          settings.setListAt( i, tiles );
          } // end loop
  
          // Save user settings in session
        session.setAttribute( userSettingsId, settings);
        } // end if
  
    return settings;
    }
  
        /**
         * Retrieve portal choices object.
         * Create it from default values if needed.
         */
      static public PortalCatalog getPortalCatalog( ComponentContext context, ServletContext servletContext)
        {
        PortalCatalog catalog = (PortalCatalog)servletContext.getAttribute( PORTAL_CATALOG_NAME );
        if( catalog == null )
          { // Initialize catalog
          catalog = new PortalCatalog();
          int numCols = Integer.parseInt( (String)context.getAttribute( NUMCOLS_ATTRIBUTE ) );
          for( int i=0; i<numCols; i++ )
            {
            List tiles = (List)context.getAttribute( ((String)LIST_ATTRIBUTE+i) );
            List labels = (List)context.getAttribute( ((String)LIST_LABELS_ATTRIBUTE+i) );
            catalog.addTiles( tiles, labels );
            } // end loop
          servletContext.setAttribute( PORTAL_CATALOG_NAME, catalog );
          } // end if
  
        return catalog;
        }
  
  }
  
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/UserMenuSettingsAction.java
  
  Index: UserMenuSettingsAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/UserMenuSettingsAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.portal;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.tiles.*;
  import org.apache.struts.tiles.actions.TilesAction;
  import org.apache.struts.tiles.beans.MenuItem;
  
  import java.io.IOException;
  import java.util.List;
  import java.util.Iterator;
  import java.util.ArrayList;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  import org.apache.struts.util.RequestUtils;
  
    /**
     * Tiles controller as Struts Action.
     * This controller take a list of lists of MenuItems, and arrange them
     * to be shown by appropriate jsp view.
     * Create and set following attribute in Tile context :
     * <ul>
     *   <li>names : list of names to display</li>
     *   <li>returnedValues : list of corresponding key, or values to return</li>
     *   <li>selecteds : list of boolean indicating whether or not a name is selected</li>
     * </ul>
   * Tiles input attributes :
   * <ul>
   *   <li>title : menu title</li>
   *   <li>items : Menu entries used as default when user settings is created</li>
   *   <li>defaultChoice : Menus or menu entries porposed as choice to user</li>
   *   <li>storeUnderName : Store user settings under provided name in session context [optional]</li>
   *   <li></li>
   * </ul>
   * Tiles output attributes :
   * <ul>
   *   <li>choiceItems : List of menu items proposed as a choice</li>
   *   <li>userItems : List of user actual menu items</li>
   * </ul>
   *
     */
  public class UserMenuSettingsAction extends TilesAction
  {
        /** debug flag */
      public static boolean debug = false;
  
        /**
       * 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 servlet The ActionServlet making this request
       * @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( ComponentContext context,
                                   ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
                            throws IOException, ServletException
      {
      if(debug)
        System.out.println("Enter action UserMenuSettingsAction");
  
      MenuSettingsForm actionForm = (MenuSettingsForm)form;
  
          // Load user menu settings and available list of choices
      MenuSettings settings = UserMenuAction.getUserSettings( request, context );
      List catalog = UserMenuAction.getCatalog( context, request, getServlet().getServletContext() );
  
        // Check if form is submitted
        // If true, read, check and store new values submitted by user.
      if( actionForm.isSubmitted() )
        {  // read arrays
        if(debug)
          System.out.println("form submitted");
  
        settings.reset();
        settings.addItems( getItems(actionForm.getSelected(), catalog) );
        if(debug)
          System.out.println( "settings : " +settings.toString() );
        actionForm.reset();
        //return null; // (mapping.findForward("viewPortal"));
        } // end if
  
        // Prepare data for view tile
      context.putAttribute( "userItems", settings.getItems() );
      context.putAttribute( "catalog", catalog );
  
      if(debug)
        System.out.println("Exit action UserMenuSettingsAction");
  	  return null;
      }
  
        /**
         * Check selected items, and return apppropriate list of items.
         * For each item in selected list, check if it exist in catalog.
         * Also check for double.
         * @param selectedKey Key of selected items (generally, link url)
         * @param catalog List of avalaible items to compare against.
         */
    static protected List getItems( String[] selectedKey, List catalog )
      {
      List selectedList = java.util.Arrays.asList( selectedKey );
      List result = new ArrayList(selectedList.size());
  
        ////////////////
      Iterator iter = selectedList.iterator();
      while( iter.hasNext() )
        {
        MenuItem item = getItem( iter.next(), catalog);
        if( item != null )
          result.add(item );
        } // end loop
      return result;
      }
        /**
         * Get item by its key in list of choices
         * @param key Key of selected items (generally, link url)
         * @param catalog List of avalaible items to compare against.
         * @return corresponding item or null if not found.
         */
    static protected MenuItem getItem( Object key, List catalog )
      {
      Iterator iter = catalog.iterator();
      while( iter.hasNext() )
        {
        MenuItem item = (MenuItem)iter.next();
        if( item.getLink().equals( key) )
          return item;
        } // end loop
      return null;
      }
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/UserMenuAction.java
  
  Index: UserMenuAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/UserMenuAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.portal;
  
  import org.apache.struts.tiles.*;
  import org.apache.struts.tiles.actions.TilesAction;
  import org.apache.struts.tiles.Controller;
  import org.apache.struts.tiles.beans.MenuItem;
  import org.apache.struts.tiles.DefinitionsUtil;
  
  import java.io.IOException;
  import java.util.Iterator;
  import java.util.List;
  import java.util.ArrayList;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.ServletContext;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  import org.apache.struts.util.RequestUtils;
  
  
  /**
   * This controller load user menu settings and put them in tile context.
   * If menu settings are not defined for user, defined them based on tiles
   * attributes used as default.
   *
   * This implementation extends Struts Action, and also define Tiles Controller interface.
   * This allows to use it as well as a controller type or a controller url. If used
   * as controller type, Struts Action functionality are not availables.
   *
   * Tiles input attributes :
   * <ul>
   *   <li>title : menu title</li>
   *   <li>items : Menu entries used as default when user settings is created</li>
   *   <li>defaultChoice : Menus or menu entries porposed as choice to user</li>
   *   <li>storeUnderName : Store user settings under provided name in session context [optional]</li>
   *   <li></li>
   * </ul>
   * Tiles output attributes :
   * <ul>
   *   <li>title : menu title</li>
   *   <li>items : Menu items to display</li>
   *   <li></li>
   * </ul>
   *
   * @author Cedric Dumoulin
   * @version $Revision: 1.1 $ $Date: 2002/07/11 15:35:20 $
   */
  
  public final class UserMenuAction extends TilesAction implements Controller {
  
        /** debug flag */
      public static boolean debug = false;
  
        /** Tile attribute containing name used to store user settings in session context */
      public static String USER_SETTINGS_NAME_ATTRIBUTE = "userSettingsName";
        /** Default name used to store settings in session context */
      public static String DEFAULT_USER_SETTINGS_NAME = "tiles.examples.portal.USER_MENU_SETTINGS";
  
        /** Default name used to store menu catalog in application scope */
      public static String DEFAULT_MENU_CATALOG_NAME = "tiles.examples.portal.MenuCatalog";
        /** Tile attribute containing name used to store menu catalog in application scope */
      public static String MENU_CATALOG_NAME_ATTRIBUTE = "catalogName";
        /** Tile attribute containing name of the settings definition used to initialize catalog */
      public static final String CATALOG_SETTING_ATTRIBUTE = "catalogSettings";
  
        /** Tile attribute containing items to render   */
      public static String USER_ITEMS_ATTRIBUTE = "items";
  
      /**
       * Struts' action perform().
       * 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 servlet The ActionServlet making this request
       * @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( ComponentContext context,
                                   ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
                            throws IOException, ServletException
      {
      perform( context, request, response, getServlet().getServletContext() );
  	  return null; //(mapping.findForward("success"));
      }
  
     /**
      * Method associated to a tile and called immediately before tile is included.
      * @param tileContext Current tile context.
      * @param request Current request
      * @param response Current response
      * @param servletContext Current servlet context
      */
     public void perform(ComponentContext context,
                         HttpServletRequest request, HttpServletResponse response,
                         ServletContext servletContext)
          throws ServletException, IOException
      {
      if(debug)
        System.out.println("Enter action UserMenuAction");
  
        // Load user settings from user context
      MenuSettings settings = getUserSettings( request, context);
        // Set parameters for rendering page
      context.putAttribute( USER_ITEMS_ATTRIBUTE, settings.getItems() );
  
      if(debug)
        {
        System.out.println( "settings=" + settings );
        System.out.println("Exit action UserMenuAction");
        }
      }
  
      /**
       * Load user setting.
       * This implementation load setting from user context.
       * If settings are not found, initialized them from default items defined
       * in Tile's context.
       * If settings are not found, initialized them.
       */
    public static MenuSettings getUserSettings( HttpServletRequest request, ComponentContext context )
      throws ServletException
    {
        // Get current session.
  	  HttpSession session = request.getSession();
  
        // Retrieve attribute name used to store settings.
      String userSettingsName = (String)context.getAttribute( USER_SETTINGS_NAME_ATTRIBUTE );
      if( userSettingsName == null )
        userSettingsName = DEFAULT_USER_SETTINGS_NAME;
  
        // Get user list from user context
      MenuSettings settings = (MenuSettings)session.getAttribute( userSettingsName );
  
        // If settings don't exist, create and initialize them
        // Initialization is done from context attribute denoted by ITEMS
      if( settings == null )
        { // List doesn't exist, create it and initialize it from Tiles parameters
        settings = new MenuSettings();
        try {
          settings.addItems( (List)context.getAttribute( USER_ITEMS_ATTRIBUTE ) );
          }
         catch( ClassCastException ex )
          {
          throw new ServletException( "Can't initialize user menu : default items must be a list of items" );
          }
          // Save user settings in session
        session.setAttribute( userSettingsName, settings);
        } // end if
  
    return settings;
    }
  
        /**
         * Get catalog of available menu entries.
         * This implementation create catalog list from the provided menu bar entries.
         *
         * as Tiles attribute.
         * Create it from default values if needed.
         */
      static public List getCatalog( ComponentContext context, HttpServletRequest request, ServletContext servletContext)
        throws ServletException
        {
          // Retrieve name used to store catalog in application context.
          // If not found, use default name
        String catalogName = (String)context.getAttribute( MENU_CATALOG_NAME_ATTRIBUTE );
        if(catalogName == null)
          catalogName = DEFAULT_MENU_CATALOG_NAME;
  
          // Get catalog from context
        List catalog = (List)servletContext.getAttribute( catalogName );
          // If not found, initialize it from provided default menu
        if( catalog == null )
          {
          Object menuBar = context.getAttribute( CATALOG_SETTING_ATTRIBUTE );
          if( menuBar == null )
            throw new ServletException( "Attribute '" + CATALOG_SETTING_ATTRIBUTE + "' must be set. It define entries used in catalog" );
          catalog = new ArrayList();
          extractItems(catalog, menuBar, request, servletContext);
          if( catalog.size() == 0 )
            throw new ServletException( "Can't initialize menu items catalog" );
  
            // save it for future use
          servletContext.setAttribute( catalogName, catalog );
          } // end if
          return catalog;
        }
        /**
         * Extract menu items from passed object. Items are stored in parameter 'result'.
         * This method allows to create a list of menu entries from existing menus.
         * Check object type class :
         * <li>
         *   <ul>MenuItems : add it</ul>
         *   <ul>ComponentDefinition : get attribute items, or list if not found.
         *       Call ExtractItems with resulting attribute.
         *   </ul>
         *   <ul>List : iterate on list, and call ExtractItems for each element.
         * </li>
         * @param result result list (should be initialized)
         * @param object object to add (MenuItems, Definition, ...)
         * @param request current request
         * @param servletContext current servlet context.
         */
      static private void extractItems( List result, Object object, HttpServletRequest request, ServletContext servletContext)
        {
        if(debug)
          System.out.println( "Extract menu item from '" + object + "'" );
        if( object instanceof String )
          {  // definition name
          try {
            ComponentDefinition def = DefinitionsUtil.getDefinition( (String)object, request, servletContext );
            extractItems( result, def, request, servletContext );
            }
           catch( Exception ex )
            { // silently fail
            }
  
          }
        else if( object instanceof List )
          {
          List list = (List)object;
          Iterator iter = list.iterator();
          while( iter.hasNext() )
            {
            extractItems( result, iter.next(), request, servletContext );
            } // end loop
          }
         else if( object instanceof ComponentDefinition )
          {
          ComponentDefinition definition = (ComponentDefinition)object;
          Object attribute = definition.getAttribute( "items" );
          if( attribute == null )
            attribute = definition.getAttribute( "list" );
          if( attribute == null )
            {
            return;
            }
          extractItems( result, attribute, request, servletContext );
          }
         else if( object instanceof MenuItem )
          {
          result.add( object );
          }
        }
  
  }
  
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/PortalSettingsForm.java
  
  Index: PortalSettingsForm.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/PortalSettingsForm.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.portal;
  
  import java.util.List;
  import java.util.ArrayList;
  import org.apache.struts.action.ActionForm;
  
  
  /**
   * Action form used to read data from web page form.
   */
  public final class PortalSettingsForm extends ActionForm  {
  
      /** Validate value */
    protected String validate;
      /** empty list used by reset */
    protected String[] empty = {};
      /** list of "remaining" choices */
    protected String[] remaining = empty;
      /** list of user columns */
    protected List columns = new ArrayList();
      /** list of user columns labels */
    protected List columnLabels = new ArrayList();
      /** list of columns selected by user */
    protected List newCols = new ArrayList();
  
      /** Choice list */
    protected List choice;
      /** Choice list labels */
    protected List choiceLabels;
      /** Is initialized ? */
    protected boolean initialized = false;
  
  
      /**
       * Set col
       */
    public void setCol( int index, List col )
      {
      columns.set( index, col);
      }
  
      /**
       * Add col
       */
    public void addCol( List col )
      {
      columns.add( col);
      }
  
      /**
       * Get col Labels
       */
    public List getColLabels(int index)
      {
      return (List)columnLabels.get(index);
      }
  
      /**
       * Set col Labels
       */
    public void setColLabels( int index, List col )
      {
      columnLabels.set( index, col);
      }
  
      /**
       * Add col Labels
       */
    public void addColLabels( List col )
      {
      columnLabels.add( col);
      }
  
      /**
       * Get col
       */
    public List getCol(int index)
      {
      return (List)columns.get(index);
      }
  
      /**
       * Set col Labels
       */
    public void setNewCol( int index, String list[] )
      {
        // ensure capacity
      while( index>=newCols.size())newCols.add(null);
      newCols.set( index, list);
      }
  
      /**
       * Get col
       */
    public String[] getNewCol(int index)
      {
      if(newCols==null || index>=newCols.size())
        return null;
      return (String[])newCols.get(index);
      }
  
      /**
       * Get number of columns
       */
    public int getNumCol()
      {
      return newCols.size();
      }
  
      /**
       * Set list1
       */
    public void setL1( String array[] )
      {
      setNewCol(1, array);
      }
      /**
       * Set list1
       */
    public String[] getL1()
      {
      return getNewCol(1);
      }
  
      /**
       * Set list1
       */
    public void setL0( String array[] )
      {
      setNewCol(0, array);
      }
      /**
       * Set list1
       */
    public String[] getL0()
      {
      return getNewCol(0);
      }
      /**
       * Set list1
       */
    public void setRemaining( String array[] )
      {
      remaining = array;
      }
      /**
       * Set list1
       */
    public String[] getRemaining()
      {
      return remaining;
      }
  
  
      /**
       * Set list1
       */
    public void setChoices( List list )
      {
      choice = list;
      }
      /**
       * Set list1
       */
    public void setChoiceLabels( List list )
      {
      choiceLabels = list;
      }
      /**
       * Set list1
       */
    public List getChoices()
      {
      return choice;
      }
      /**
       * Set list1
       */
    public List getChoiceLabels()
      {
      return choiceLabels;
      }
  
     /**
      * Is this form submitted ?
      */
    public boolean isSubmitted()
      {
      return validate != null;
      }
  
     /**
      * Is this form submitted ?
      */
    public void setValidate( String value)
      {
      this.validate = value;
      }
  
      /**
       * Reset properties
       */
    public void reset()
      {
      remaining =  empty;
      validate = null;
      columns.clear();
      columnLabels.clear();
      newCols.clear();
      }
      /**
       * Initialized flag
       */
    public boolean isInitialized()
      {
      return initialized;
      }
      /**
       * Initialized flag
       */
    public void setInitialized( boolean isInitialized)
      {
      initialized = isInitialized;
      }
  }
  
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/PortalSettings.java
  
  Index: PortalSettings.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/PortalSettings.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.portal;
  
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.HashMap;
  
    /**
     * Objects of this class hold portal settings for one user.
     */
     public class PortalSettings
     {
         /** Number of columms*/
       protected int numCols;
         /** List of lists (one per column) */
       protected List lists = new ArrayList();
  
         /**
          * Get number of columns.
          */
       public int getNumCols()
         {
         return numCols;
         }
         /**
          * Set number of columns
          */
       public void setNumCols( String numCols )
         {
         setNumCols( Integer.parseInt(numCols) );
         }
         /**
          * Set number of columns.
          * Ensure capacity for internal list.
          */
       public void setNumCols( int numCols )
         {
         this.numCols = numCols;
         }
         /**
          * Get list at specified index
          */
       public List getListAt( int index )
         {
         return (List)lists.get(index);
         }
  
         /**
          * Add a list without checking
          */
       public void addList( List list )
         {
         lists.add( list);
         }
  
         /**
          * Set list at specified index. Previous list is disguarded.
          * Add empty list if necessary.
          * Indexes go from 0 to numCols-1
          * @param index index of the list to add.
          * @param list list to set.
          */
       public void setListAt( int index, List list )
         {
           // First, ensure capacity
         while( index>lists.size() ) lists.add(new ArrayList());
         lists.add( index, list);
         }
  
         /**
          * Reset settings
          */
       public void reset()
         {
         numCols = 0;
         lists.clear();
         }
  
       public String toString()
         {
         return "colCount=" + numCols
                + " , lists=" + lists;
         }
     }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/PortalCatalog.java
  
  Index: PortalCatalog.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/PortalCatalog.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.portal;
  
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.HashMap;
  
  
  /**
   * A catalog of available tiles for a portal.
   * Tiles denote a local URL or a Tile definition name.
   * To check : should be possible to put ComponentDefinition class also.
   *
   * @author Cedric Dumoulin
   */
  public class PortalCatalog
  {
         /** List of available Tiles */
       protected List tiles = new ArrayList();
         /** List of Tiles labels */
       protected List tileLabels = new ArrayList();
  
         /**
          * Set list of tiles.
          * Labels come from tiles names
          * @param list list of tiles
          */
       public void setTiles( List list)
         {
         setTiles(list, list);
         }
  
         /**
          * add list to list of available Tiles
          * Labels come from tiles names
          * @param list list of tiles
          */
       public void addTiles( List list)
         {
         addTiles( list, list);
         }
  
         /**
          * Set list of available Tiles.
          * Previous list is disguarded.
          * @param list list of tiles
          * @param labels corresponding labels. List size must be the same as list.
          * If labels is null, use list of tiles.
          * @throws ArrayIndexOutOfBoundsException if list and labels aren't the same size.
          */
       public void setTiles( List list, List labels)
           throws ArrayIndexOutOfBoundsException
         {
           // If no labels, use list keys
         if( labels == null )
           labels = list;
           // Check sizes
         if( list.size() != labels.size() )
           {// error
           System.out.println( "Error : list and labels size must be the same." );
           throw new java.lang.ArrayIndexOutOfBoundsException( "List of tiles and list of labels must be of the same size" );
           }
         this.tiles = list;
         tileLabels = labels;
         }
  
         /**
          * add list and labels to list of available Tiles.
          * If labels is null, use keys list as labels.
          * @list list of choice keys to add
          * @param labels corresponding labels. List size must be the same as list.
          * If labels is null, use list of tiles.
          * @throws ArrayIndexOutOfBoundsException if list and labels aren't the same size.
          */
       public void addTiles( List list, List labels)
           throws ArrayIndexOutOfBoundsException
         {
           // If no labels, use list keys
         if( labels == null )
           labels = list;
           // Check sizes
          if(tiles== null)
           {
           setTiles(list, labels);
           return;
           }
  
         if( list.size() != labels.size() )
           {// error
           System.out.println( "Error : list and labels size must be the same." );
           throw new java.lang.ArrayIndexOutOfBoundsException( "List of tiles and list of labels must be of the same size" );
           }
         tiles.addAll(list);
         tileLabels.addAll(labels);
         }
  
         /**
          * Get list of available Tiles
          */
       public List getTiles( )
         {
         return tiles;
         }
  
         /**
          * Get list of labels for Tiles
          */
       public List getTilesLabels( )
         {
         return tileLabels;
         }
  
         /**
          * Get label for specified Tile, identified by its key.
          * @param key Tile key
          */
       public String getTileLabel( Object key )
         {
         int index = tiles.indexOf( key );
         if(index==-1)
           return null;
         return (String)tileLabels.get(index);
         }
  
         /**
          * Get list of labels for Tile keys
          * @param keys List of keys to search for labels.
          */
       public List getTileLabels( List Keys )
         {
         List listLabels = new ArrayList();
  
         Iterator i = Keys.iterator();
         while(i.hasNext())
           {
           Object key = i.next();
           listLabels.add( getTileLabel(key) );
           } // end loop
         return listLabels;
         }
  
         /**
          * Get Tiles corresponding to keys.
          * Keys are the one returned by the setting page. Keys are usually issue
          * from values returned by getTiles().
          * If a key isn't recognize, it is disguarded from the returned list.
          * If a key correspond to a special key, appropriate 'definition' is created.
          * Returned list contains tiles URL, definition name and definitions suitable
          * as attribute of <tiles:insert >.
          *
          * @keys array of keys to add to list.
          */
       public List getTiles( String keys[] )
         {
         List list = new ArrayList();
  
           // add keys to list
         for(int i=0;i<keys.length;i++)
           {
           String key = keys[i];
           if( key.indexOf( '@' )>0 )
             { // special key
             }
           if( tiles.contains( key ) )
             { // ok, add it
             list.add( key );
             }
           } // end loop
         return list;
         }
  
         /**
          * Set labels for tiles Tiles.
          */
       protected void setTileLabels( List list)
         {
         this.tileLabels = list;
         }
         /**
          * add list to list of tiles Tiles
          */
       protected void addTileLabels( List list)
         {
         if(tileLabels== null)
           {
           setTileLabels(list);
           return;
           }
         tileLabels.addAll(list);
         }
  
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/MenuSettingsForm.java
  
  Index: MenuSettingsForm.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/MenuSettingsForm.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.portal;
  
  import java.util.List;
  import java.util.ArrayList;
  import org.apache.struts.action.ActionForm;
  
  
  /**
   * Action form used to read data from web page form.
   */
  public final class MenuSettingsForm extends ActionForm  {
  
      /** Validate value */
    protected String validate;
      /** empty list used by reset */
    protected String[] empty = {};
      /** list of items selected by user */
    protected String[] selected;
  
      /**
       * Set selected items
       */
    public void setSelected( String array[] )
      {
      selected = array;
      }
  
      /**
       * Get selected items
       */
    public String[] getSelected()
      {
      return selected;
      }
  
      /**
       * Get selected items
       */
    public String[] getSelectedChoices()
      {
      return empty;
      }
  
     /**
      * Is this form submitted ?
      */
    public boolean isSubmitted()
      {
      return validate != null;
      }
  
     /**
      * Is this form submitted ?
      */
    public void setValidate( String value)
      {
      this.validate = value;
      }
  
      /**
       * Reset properties
       */
    public void reset()
      {
      selected =  empty;
      validate = null;
      }
  }
  
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/MenuSettings.java
  
  Index: MenuSettings.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/portal/MenuSettings.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.portal;
  
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.HashMap;
  
    /**
     * Objects of this class hold menu settings for one user.
     */
     public class MenuSettings
     {
         /** List of items */
       protected List items = new ArrayList();
  
         /**
          * Get list of items
          */
       public List getItems( )
         {
         return items;
         }
  
         /**
          * Add an item to the list
          */
       public void addItem( Object item )
         {
         items.add( item );
         }
  
         /**
          * Add all items to the list.
          */
       public void addItems( List list )
         {
         items.addAll( list );
         }
  
         /**
          * Reset settings
          */
       public void reset()
         {
         items.clear();
         }
  
       public String toString()
         {
         return "items=" + items;
         }
     }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/test/TestTileController.java
  
  Index: TestTileController.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/test/TestTileController.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.test;
  
  import org.apache.struts.tiles.ControllerSupport;
  import org.apache.struts.tiles.ComponentContext;
  
  import java.io.IOException;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.ServletContext;
  
  
    /**
     * Controller example.
     * This controller modify title by adding "ok".
     * @author Cedric Dumoulin
     */
  public class TestTileController extends ControllerSupport
  {
  
    public TestTileController()
      {
      }
  
     /**
      * Method associated to a tile and called when immediately before tile is included.
      * @param tileContext Current tile context.
      * @param request Current request
      * @param response Current response
      * @param servletContext Current servlet context
      */
     public void perform(ComponentContext tileContext,
                         HttpServletRequest request, HttpServletResponse response,
                         ServletContext servletContext)
          throws ServletException, IOException
     {
     System.out.println( "Controller called" );
  
  
     String title = (String)tileContext.getAttribute("title");
     title += "- controller called";
     tileContext.putAttribute( "title", title);
     }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/test/TestActionTileAction.java
  
  Index: TestActionTileAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/test/TestActionTileAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.test;
  
  import org.apache.struts.tiles.*;
  
  import java.io.IOException;
  import java.util.Locale;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  import org.apache.struts.util.RequestUtils;
  
  
  /**
   * Implementation of <strong>Action</strong> that populates an instance of
   * <code>SubscriptionForm</code> from the currently specified subscription.
   *
   * @author Craig R. McClanahan
   * @author Cedric Dumoulin
   * @version $Revision: 1.1 $ $Date: 2002/07/11 15:35:20 $
   */
  
  public final class TestActionTileAction extends Action {
  
  
      // --------------------------------------------------------- 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 servlet The ActionServlet making this request
       * @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 {
  
        // Try to retrieve tile context
      ComponentContext context = ComponentContext.getContext( request );
      if( context == null )
        {
        request.setAttribute( "actionError", "Can't get component context.");
        return (mapping.findForward("failure"));
        }
        // Get requested test from tile parameter
      String param;
  
        // Set a definition in this action
      param = (String)context.getAttribute( "set-definition-name" );
      if( param != null )
        {
        try
          {
            // Read definition from factory, but we can create it here.
          ComponentDefinition definition = DefinitionsUtil.getDefinition( param, request, getServlet().getServletContext() );
          //definition.putAttribute( "attributeName", "aValue" );
          DefinitionsUtil.setActionDefinition( request, definition);
          }
         catch( FactoryNotFoundException ex )
          {
          request.setAttribute( "actionError", "Can't get definition factory.");
          return (mapping.findForward("failure"));
          }
         catch( NoSuchDefinitionException ex )
          {
          request.setAttribute( "actionError", "Can't get definition '" + param +"'.");
          return (mapping.findForward("failure"));
          }
         catch( DefinitionsFactoryException ex )
          {
          request.setAttribute( "actionError", "General error '" + ex.getMessage() +"'.");
          return (mapping.findForward("failure"));
          }
        }
  
        // Overload a parameter
      param = (String)context.getAttribute( "set-attribute" );
      if( param != null )
        {
        context.putAttribute( param, context.getAttribute( "set-attribute-value" ));
        } // end if
  
  	  return (mapping.findForward("success"));
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/SimpleSwitchLayoutAction.java
  
  Index: SimpleSwitchLayoutAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/SimpleSwitchLayoutAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.skin;
  
  import org.apache.struts.tiles.DefinitionsUtil;
  import org.apache.struts.tiles.DefinitionsFactoryException;
  import org.apache.struts.tiles.definition.ReloadableDefinitionsFactory;
  
  import org.apache.struts.tiles.ComponentContext;
  import org.apache.struts.tiles.actions.TilesAction;
  import org.apache.struts.tiles.ComponentDefinition;
  import org.apache.struts.tiles.DefinitionsFactoryException;
  import org.apache.struts.tiles.FactoryNotFoundException;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.Map;
  import java.util.HashMap;
  
  import javax.servlet.ServletException;
  import javax.servlet.ServletContext;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import javax.servlet.RequestDispatcher;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
    /**
     * Simple Switch Layout
     */
  public class SimpleSwitchLayoutAction extends TilesAction
  {
      /** debug flag */
    public static boolean debug = true;
      /** Tile's attribute containing layout key */
    public static final String LAYOUT_ATTRIBUTE = "layout.attribute";
      /** Tile attribute containing name used to store user settings in session context */
    public static String USER_SETTINGS_NAME_ATTRIBUTE = "userSettingsName";
      /** Default name used to store settings in session context */
    public static String DEFAULT_USER_SETTINGS_NAME = "examples.tiles.skin.SELECTED_DEFINITION";
  
      /** Name of catalog in application context */
    public static final String CATALOG_NAME = "examples.tiles.skin.CATALOG_NAME";
  
      /** Default name used to store menu catalog in application scope */
    public static String DEFAULT_CATALOG_NAME = "tiles.examples.skin.layoutCatalog";
      /** Tile attribute containing name used to store menu catalog in application scope */
    public static String CATALOG_NAME_ATTRIBUTE = "catalogName";
      /** Tile attribute containing name of the settings definition used to initialize catalog */
    public static final String CATALOG_SETTING_ATTRIBUTE = "catalogSettings";
  
      /**
       * 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.
       * This method should be implemented by subclasses.
       *
       * @param context The current Tile context, containing Tile attributes
       * @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( ComponentContext context,
                                   ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
                            throws IOException, ServletException
      {
      if(debug)
        System.out.println( "Enter SimpleSwitchLayoutAction"  );
  
      String layoutDir = "/layouts/";
      String userSelection = getUserSetting( context, request );
      //String layout = "classicLayout.jsp";
      String layout = (String)context.getAttribute( LAYOUT_ATTRIBUTE );
      if(layout==null)
        throw new ServletException( "Attribute '" + LAYOUT_ATTRIBUTE + "' is required." );
  
      String layoutPath = layoutDir+userSelection+ "/" + layout;
  
      RequestDispatcher rd = getServlet().getServletContext().getRequestDispatcher( layoutPath );
      if(rd==null)
        {
        layoutPath = layoutDir + layout;
        rd = getServlet().getServletContext().getRequestDispatcher( layoutPath );
        if(rd==null)
          throw new ServletException( "SwitchLayout error : Can't find layout '"
                                    + layoutPath + "'." );
        }
      rd.include(request, response);
      if(debug)
        System.out.println( "Exit  SimpleSwitchLayoutAction"  );
      return null;
      }
  
      /**
       * Retrieve key associated to user.
       * This key denote a definition in catalog.
       * Return user selected key, or "default" if none is set.
       */
    public static String getUserSetting( ComponentContext context, HttpServletRequest request )
    {
    HttpSession session = request.getSession( false );
    if( session == null )
      return null;
  
      // Retrieve attribute name used to store settings.
    String userSettingsName = (String)context.getAttribute( USER_SETTINGS_NAME_ATTRIBUTE );
    if( userSettingsName == null )
      userSettingsName = DEFAULT_USER_SETTINGS_NAME;
  
    return (String)session.getAttribute(userSettingsName);
    }
  
      /**
       * Set user setting value.
       * This key denote a definition in catalog.
       * Return user selected key, or "default" if none is set.
       */
    public static void setUserSetting( ComponentContext context, HttpServletRequest request, String setting )
    {
    HttpSession session = request.getSession();
  
      // Retrieve attribute name used to store settings.
    String userSettingsName = (String)context.getAttribute( USER_SETTINGS_NAME_ATTRIBUTE );
    if( userSettingsName == null )
      userSettingsName = DEFAULT_USER_SETTINGS_NAME;
  
    session.setAttribute(userSettingsName, setting);
    }
  
      /**
       * Get catalog of available skins.
       */
    public static DefinitionCatalog getCatalog( ComponentContext context, HttpServletRequest request, ServletContext servletContext )
      throws ServletException
    {
      // Retrieve name used to store catalog in application context.
      // If not found, use default name
    String catalogName = (String)context.getAttribute( CATALOG_NAME_ATTRIBUTE );
    if(catalogName == null)
      catalogName = DEFAULT_CATALOG_NAME;
  
    if(debug)
      System.out.println( "Catalog name=" + catalogName );
    try
      {
      DefinitionCatalog catalog = (DefinitionCatalog)servletContext.getAttribute( catalogName );
      if(catalog == null)
        { // create catalog
        if(debug)
          System.out.println( "Create catalog" );
        String catalogSettings = (String)context.getAttribute( CATALOG_SETTING_ATTRIBUTE );
        if(catalogSettings == null)
          throw new ServletException( "Error - CustomSkinAction : attribute '"
                                    + CATALOG_SETTING_ATTRIBUTE
                                    + "' not found in Tile's attributes. Need it to initialize catalog"  );
        catalog = new DefinitionCatalog( catalogSettings, request, servletContext );
        if(debug)
          System.out.println( "Catalog created" );
        servletContext.setAttribute( catalogName, catalog );
        } // end if
      return catalog;
      }
     catch(DefinitionsFactoryException ex )
      {
      if(debug)
          System.out.println( "Exception : " + ex.getMessage() );
      throw new ServletException( ex.getMessage() );
      }
    }
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/LayoutSwitchAction.java
  
  Index: LayoutSwitchAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/LayoutSwitchAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.skin;
  
  import org.apache.struts.tiles.DefinitionsUtil;
  import org.apache.struts.tiles.DefinitionsFactoryException;
  import org.apache.struts.tiles.definition.ReloadableDefinitionsFactory;
  
  import org.apache.struts.tiles.ComponentContext;
  import org.apache.struts.tiles.actions.TilesAction;
  import org.apache.struts.tiles.ComponentDefinition;
  import org.apache.struts.tiles.DefinitionsFactoryException;
  import org.apache.struts.tiles.FactoryNotFoundException;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.Map;
  import java.util.HashMap;
  
  import javax.servlet.ServletException;
  import javax.servlet.ServletContext;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import javax.servlet.RequestDispatcher;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
    /**
     * Customize layouts according to predefined "skin"
     * A "skin" is a set of layouts used together to provide a consistent
     * Look & Feel.
     * This action is called when inserting a definition's layout. It replaces
     * definition's layout by the one set in selected skin.
     * the appropriate
     * Available skins are stored in application context. They are initialized from
     * a Tile definition.
     * Currently selected skin is stored under user session, if any. Otherwise,
     * the default skin is used.
     * This action act for all layouts. A Tile's attribute (skinLayout) is used as a key to
     * know which layouts is concerned.
     */
  public class LayoutSwitchAction extends TilesAction
  {
      /** debug flag */
    public static boolean debug = true;
      /** Tile's attribute containing layout key */
    public static final String LAYOUT_ATTRIBUTE = "layout.attribute";
      /** Tile attribute containing name used to store user settings in session context */
    public static String USER_SETTINGS_NAME_ATTRIBUTE = "userSettingsName";
      /** Default name used to store settings in session context */
    public static String DEFAULT_USER_SETTINGS_NAME = "examples.tiles.skin.SELECTED_DEFINITION";
  
      /** Name of catalog in application context */
    public static final String CATALOG_NAME = "examples.tiles.skin.CATALOG_NAME";
  
      /** Default name used to store menu catalog in application scope */
    public static String DEFAULT_CATALOG_NAME = "tiles.examples.skin.layoutCatalog";
      /** Tile attribute containing name used to store menu catalog in application scope */
    public static String CATALOG_NAME_ATTRIBUTE = "catalogName";
      /** Tile attribute containing name of the settings definition used to initialize catalog */
    public static final String CATALOG_SETTING_ATTRIBUTE = "catalogSettings";
  
      /**
       * 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.
       * This method should be implemented by subclasses.
       *
       * @param context The current Tile context, containing Tile attributes
       * @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( ComponentContext context,
                                   ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
                            throws IOException, ServletException
      {
      if(debug)
        System.out.println( "EnterLayoutSwitchAction"  );
        // Get attribute value indicating which layout we want
      String layoutKey = (String)context.getAttribute( LAYOUT_ATTRIBUTE );
      if(layoutKey==null)
        throw new ServletException( "Error - CustomSkinAction : attribute '"
                                    + LAYOUT_ATTRIBUTE
                                    + "' not found in Tile's attributes. Need it to select appropriate layout"  );
  
        // Get user current skin
      ComponentDefinition definition = getCurrentDefinition( context, request, getServlet().getServletContext() );
        // get requested layout from definition
      String layout = (String)definition.getAttribute(layoutKey);
      if(layout==null)
        throw new ServletException( "Error - CustomSkinAction : no layout defined for key '"
                                    + layoutKey
                                    + "' in currently selected skin '"
                                    + getUserSetting(context, request ) + "'."  );
        // set path to forward to
        // Not very nice solution, need to improve it
      /*
      ComponentDefinition forwarDefinition = new ComponentDefinition( "", layout, new HashMap() );
      DefinitionsUtil.setActionDefinition( request, forwarDefinition );
      */
      if(debug)
        System.out.println( "Switch to : " + layout  );
      RequestDispatcher rd = getServlet().getServletContext().getRequestDispatcher( layout );
      if(rd==null)
        throw new ServletException( "LayoutSwitch error : Can't find layout '"
                                    + layout + "'." );
      rd.include(request, response);
      if(debug)
        System.out.println( "Exit  LayoutSwitchAction"  );
      return null;
      }
  
      /**
       * Retrieve key associated to user.
       * This key denote a definition in catalog.
       * Return user selected key, or "default" if none is set.
       */
    public static String getUserSetting( ComponentContext context, HttpServletRequest request )
    {
    HttpSession session = request.getSession( false );
    if( session == null )
      return null;
  
      // Retrieve attribute name used to store settings.
    String userSettingsName = (String)context.getAttribute( USER_SETTINGS_NAME_ATTRIBUTE );
    if( userSettingsName == null )
      userSettingsName = DEFAULT_USER_SETTINGS_NAME;
  
    return (String)session.getAttribute(userSettingsName);
    }
  
      /**
       * Set user setting value.
       * This key denote a definition in catalog.
       * Return user selected key, or "default" if none is set.
       */
    public static void setUserSetting( ComponentContext context, HttpServletRequest request, String setting )
    {
    HttpSession session = request.getSession();
  
      // Retrieve attribute name used to store settings.
    String userSettingsName = (String)context.getAttribute( USER_SETTINGS_NAME_ATTRIBUTE );
    if( userSettingsName == null )
      userSettingsName = DEFAULT_USER_SETTINGS_NAME;
  
    session.setAttribute(userSettingsName, setting);
    }
  
      /**
       * Get currently selected skin definition.
       */
    public static ComponentDefinition getCurrentDefinition( ComponentContext context, HttpServletRequest request, ServletContext servletContext )
      throws ServletException
    {
      // Get selected key
    String selected = getUserSetting(context, request);
  
    DefinitionCatalog catalog = getCatalog( context, request, servletContext);
    ComponentDefinition definition =  (ComponentDefinition)catalog.get( selected );
    if( definition == null )
      definition = (ComponentDefinition)catalog.getDefault();
  
    return definition;
    }
  
      /**
       * Get catalog of available skins.
       */
    public static DefinitionCatalog getCatalog( ComponentContext context, HttpServletRequest request, ServletContext servletContext )
      throws ServletException
    {
      // Retrieve name used to store catalog in application context.
      // If not found, use default name
    String catalogName = (String)context.getAttribute( CATALOG_NAME_ATTRIBUTE );
    if(catalogName == null)
      catalogName = DEFAULT_CATALOG_NAME;
  
    if(debug)
      System.out.println( "Catalog name=" + catalogName );
    try
      {
      DefinitionCatalog catalog = (DefinitionCatalog)servletContext.getAttribute( catalogName );
      if(catalog == null)
        { // create catalog
        if(debug)
          System.out.println( "Create catalog" );
        String catalogSettings = (String)context.getAttribute( CATALOG_SETTING_ATTRIBUTE );
        if(catalogSettings == null)
          throw new ServletException( "Error - CustomSkinAction : attribute '"
                                    + CATALOG_SETTING_ATTRIBUTE
                                    + "' not found in Tile's attributes. Need it to initialize catalog"  );
        catalog = new DefinitionCatalog( catalogSettings, request, servletContext );
        if(debug)
          System.out.println( "Catalog created" );
        servletContext.setAttribute( catalogName, catalog );
        } // end if
      return catalog;
      }
     catch(DefinitionsFactoryException ex )
      {
      if(debug)
          System.out.println( "Exception : " + ex.getMessage() );
      throw new ServletException( ex.getMessage() );
      }
    }
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/LayoutSettingsForm.java
  
  Index: LayoutSettingsForm.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/LayoutSettingsForm.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.skin;
  
  import org.apache.struts.action.ActionForm;
  
  /**
   * Struts form
   */
  public class LayoutSettingsForm extends ActionForm
  {
  
      /** Validate value */
    protected String validate;
  
     /**
      * User selected key value
      */
     private String selected;
  
     /**
      * Access method for the selectedKey property.
      *
      * @return   the current value of the selectedKey property
      */
     public String getSelected()
     {
        return selected;
     }
  
     /**
      * Sets the value of the selectedKey property.
      *
      * @param aSelectedKey the new value of the selectedKey property
      */
     public void setSelected(String aSelectedKey)
     {
        selected = aSelectedKey;
     }
     /**
      * Is this form submitted ?
      */
    public boolean isSubmitted()
      {
      return validate != null;
      }
  
     /**
      * Is this form submitted ?
      */
    public void setValidate( String value)
      {
      this.validate = value;
      }
  
      /**
       * Reset properties
       */
    public void reset()
      {
      selected =  null;
      validate = null;
      }
  
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/LayoutSettingsAction.java
  
  Index: LayoutSettingsAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/LayoutSettingsAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.skin;
  
  import org.apache.struts.tiles.actions.TilesAction;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.tiles.ComponentContext;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionForm;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import java.io.IOException;
  import javax.servlet.ServletException;
  
  /**
   * Action used to set user skin.
   */
  public class LayoutSettingsAction extends TilesAction
  {
        /** debug flag */
      public static boolean debug = true;
  
      /**
       * 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.
       * This method should be implemented by subclasses.
       *
       * @param context The current Tile context, containing Tile attributes
       * @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( ComponentContext context,
                                   ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
                            throws IOException, ServletException
     {
      if(debug)
        System.out.println("Enter action LayoutSettingAction");
  
      LayoutSettingsForm actionForm = (LayoutSettingsForm)form;
  
          // Load user menu settings and available list of choices
      String  selected = LayoutSwitchAction.getUserSetting( context, request );
      if(selected==null)
        selected = "default";
      System.out.println("user setting retrieved");
      DefinitionCatalog catalog = LayoutSwitchAction.getCatalog( context, request, getServlet().getServletContext() );
      System.out.println("catalog retrieved");
  
        // Check if form is submitted
        // If true, read, check and store new values submitted by user.
      if( actionForm.isSubmitted() )
        {  // read arrays
        if(debug)
          System.out.println("form submitted");
        selected = catalog.getKey(actionForm.getSelected());
        if(debug)
          System.out.println( "key : " + selected );
        LayoutSwitchAction.setUserSetting(context, request, selected );
        if(debug)
          System.out.println( "settings : " + selected );
        actionForm.reset();
        } // end if
  
        // Prepare data for view tile
      context.putAttribute( "selected", selected );
      context.putAttribute( "catalog", catalog );
  
      if(debug)
        System.out.println("Exit action LayoutSettingAction");
      return null;
     }
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/DefinitionCatalog.java
  
  Index: DefinitionCatalog.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/skin/DefinitionCatalog.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.skin;
  
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Map;
  import java.util.HashMap;
  import java.util.Iterator;
  
  import org.apache.struts.tiles.ComponentDefinition;
  import org.apache.struts.tiles.DefinitionsUtil;
  import org.apache.struts.tiles.FactoryNotFoundException;
  import org.apache.struts.tiles.DefinitionsFactoryException;
  import org.apache.struts.tiles.NoSuchDefinitionException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.ServletContext;
  
  /**
   * A catalog of available definitions.
   */
  public class DefinitionCatalog
  {
        /** debug flag */
      public static boolean debug = true;
      /** Attribute carrying definition readable name */
     public static final String LABEL_NAME_ATTRIBUTE = "skin.label";
      /** Attribute carrying the list of definition names */
     public static final String DEFINITION_LIST_ATTRIBUTE = "skin.list";
  
     /**
      * Map of skins, by their keys
      */
     private Map definitions = new HashMap();
     /**
      * Map of skins, by their keys
      */
     private ComponentDefinition defaultDefinition;
  
     /**
      * List of names
      */
     private List names = new ArrayList();
  
     /**
      * List of keys
      */
     private List keys = new ArrayList();
  
     /**
      * Constructor.
      * Initialize catalog from definitions factory.
      * @param HttpRequest request
      * @param ServletContext context
      * @throws FactoryNotFoundException, DefinitionsFactoryException
      */
     public DefinitionCatalog( String catalogName, HttpServletRequest request, ServletContext context)
       throws FactoryNotFoundException, DefinitionsFactoryException
     {
       // Get definition containing list of definitions
     ComponentDefinition catalogDef = DefinitionsUtil.getDefinition( catalogName, request, context);
     if(debug)
       System.out.println( "Got definition " + catalogDef );
       // Get list of definition names
     List list = (List)catalogDef.getAttribute( DEFINITION_LIST_ATTRIBUTE );
     Iterator i = list.iterator();
     while(i.hasNext() )
       {
       String name = (String)i.next();
       System.out.println( "add " + name );
       ComponentDefinition def = DefinitionsUtil.getDefinition(name, request, context);
       if(def==null)
         throw new NoSuchDefinitionException("Can't find definition '" + name + "'" );
       add( name, def );
       } // end loop
     if(debug)
       System.out.println( "Catalog initialized" );
     }
  
     /**
      * Get definition identified by key.
      * @param key
      * @return Definition associated to key
      */
     public ComponentDefinition get(Object key)
     {
     if(key==null)
       return getDefault();
     return (ComponentDefinition)definitions.get(key);
     }
  
     /**
      * Get definition identified by key.
      * @param key
      * @return Definition associated to key
      */
     public ComponentDefinition getDefault()
     {
     return defaultDefinition;
     }
  
     /**
      * Return List of names of definitions presents in catalog.
      * Names are user readable names. Returned list has the same order as list
      * returned by getKeys.
      * @return List
      */
     public List getNames()
     {
      return names;
     }
  
     /**
      * Get list of keys of definitions present in catalog.
      * A key is used to retrieve a skin from catalog.
      * @return List
      */
     public List getKeys()
     {
      return keys;
     }
  
     /**
      * Check if requested key is valid in catalog.
      * Return null otherwise
      * @return valid key or null
      */
     public String getKey( String key )
     {
     if( definitions.get(key) != null)
      return key;
  
     return null;
     }
  
     /**
      * Add a skin definition
      * @param definition
      */
     public void add(String key, ComponentDefinition definition)
     {
       // Intitialize default definition with first definition encountered
     if( defaultDefinition == null )
       {
       defaultDefinition = definition;
       }
       // store definition
     definitions.put( key , definition);
     Object name = definition.getAttribute(LABEL_NAME_ATTRIBUTE);
     if( name == null )
       name = key;
     names.add( name );
     keys.add(key);
     }
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dynPortal/SetPortalPrefsAction.java
  
  Index: SetPortalPrefsAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dynPortal/SetPortalPrefsAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.dynPortal;
  
  import org.apache.struts.tiles.*;
  
  import java.io.IOException;
  import java.util.Locale;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  import org.apache.struts.util.RequestUtils;
  
  
  /**
   * Implementation of <strong>Action</strong> that populates an instance of
   * <code>SubscriptionForm</code> from the currently specified subscription.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/07/11 15:35:20 $
   */
  
  public final class SetPortalPrefsAction extends Action {
  
  
      // --------------------------------------------------------- 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 servlet The ActionServlet making this request
       * @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
    {
      System.out.println("Enter action SetPortalPrefsAction");
  	HttpSession session = request.getSession();
    PortalPrefsForm prefsForm = (PortalPrefsForm)form;
  
            // Try to retrieve tile context
      ComponentContext context = ComponentContext.getContext( request );
      if( context == null )
        {
        throw new ServletException( "This action must be called by a Tile, not directly" );
        }
  
        // Get user portal list from user context
      PortalSettings settings = RetrievePortalAction.getSettings( context, session );
  
    if( prefsForm.isSubmitted() )
      {  // read arrays
      System.out.println("form submitted");
  
        // Set settings cols according to user choice
      for( int i=0;i<prefsForm.getNumCol(); i++)
        {
        settings.resetListAt( i, prefsForm.getNewCol(i));
        } // end loop
  
  
      //settings.resetListAt( 0, prefsForm.getL0());
      //settings.resetListAt( 1, prefsForm.getL1());
      prefsForm.reset();
  	  return (mapping.findForward("portal"));
      }
  
        // Set lists values to be shown
      for( int i=0;i<settings.getNumCols(); i++ )
        {
        prefsForm.addCol(settings.getListAt(i) );
        prefsForm.addColLabels(settings.getListLabelAt(i) );
        } // end loop
  
      prefsForm.setChoices(settings.getChoices() );
      prefsForm.setChoiceLabels(settings.getChoiceLabels() );
  
      System.out.println("Exit action SetPortalPrefsAction");
  	  return (mapping.findForward("preferences"));
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dynPortal/RetrievePortalAction.java
  
  Index: RetrievePortalAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dynPortal/RetrievePortalAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.dynPortal;
  
  import org.apache.struts.tiles.*;
  
  import java.io.IOException;
  import java.util.Locale;
  //import java.util.Vector;
  import java.util.List;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  import org.apache.struts.util.RequestUtils;
  
  
  /**
   * Implementation of <strong>Action</strong> that populates an instance of
   * <code>SubscriptionForm</code> from the currently specified subscription.
   *
   * @author Craig R. McClanahan
   * @author Cedric Dumoulin
   */
  
  public final class RetrievePortalAction extends Action {
  
        /** Name use to store settings in session context */
      public static String USER_PORTAL_SETTINGS = "DynamicPortal.USER_PORTAL_SETTINGS";
        /** Tile parameter name */
      public static String PARAM_NUMCOLS = "numCols";
        /** Tile parameter name */
      public static String PARAM_LIST = "list";
        /** Tile parameter name */
      public static String PARAM_LIST_LABELS = "listLabels";
      // --------------------------------------------------------- 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 servlet The ActionServlet making this request
       * @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
      {
      System.out.println("Enter action RetrievePortalAction");
        // Get current session.
  	  HttpSession session = request.getSession();
  
            // Try to retrieve tile context
      ComponentContext context = ComponentContext.getContext( request );
      if( context == null )
        {
        throw new ServletException( "This action must be called by a Tile, not directly" );
        }
  
        // Get user portal list from user context
      PortalSettings settings = getSettings( context, session );
  
        // Set parameters for tiles
      context.putAttribute( "numCols", Integer.toString(settings.getNumCols()) );
      for( int i=0; i<settings.getNumCols(); i++ )
        context.putAttribute( "list"+i, settings.getListAt(i) );
  
      System.out.println("Exit action RetrievePortalAction");
  	  return (mapping.findForward("success"));
      }
  
      /**
       * Retrieve user setting from session.
       * If settings are not found, initialized them.
       */
    public static PortalSettings getSettings( ComponentContext context, HttpSession session )
    {
        // Get user portal list from user context
      PortalSettings settings = (PortalSettings)session.getAttribute( USER_PORTAL_SETTINGS );
  
      if( settings == null )
        { // List doesn't exist, create it and initialize it from Tiles parameters
        settings = new PortalSettings();
        settings.setNumCols( (String)context.getAttribute( PARAM_NUMCOLS ) );
        for( int i=0; i<settings.getNumCols(); i++ )
          {
          List col = (List)context.getAttribute( ((String)PARAM_LIST+i) );
          List labels = (List)context.getAttribute( ((String)PARAM_LIST_LABELS+i) );
          settings.addChoices( col, labels );
          settings.addList( col );
          } // end loop
  
          // Save user settings in session
        session.setAttribute( USER_PORTAL_SETTINGS, settings);
        } // end if
  
    return settings;
    }
  
  
  }
  
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dynPortal/PortalSettings.java
  
  Index: PortalSettings.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dynPortal/PortalSettings.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.dynPortal;
  
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.HashMap;
  
    /**
     * Objects of this class hold portal settings for one user.
     */
     public class PortalSettings
     {
         /** Number of columms*/
       protected int numCols;
         /** List of lists (one per column) */
       protected List lists = new ArrayList();
         /** Choices Tiles */
       protected List choices = new ArrayList();
         /** Choices Tiles labels */
       protected List choiceLabels = new ArrayList();
  
         /**
          * Get label for specified Tile, identified by its key.
          */
       public String getLabel( Object key )
         {
         int index = choices.indexOf( key );
         return (String)choiceLabels.get(index);
         }
  
         /**
          * Get number of columns.
          */
       public int getNumCols()
         {
         return numCols;
         }
         /**
          * Set number of columns
          */
       public void setNumCols( String numCols )
         {
         this.numCols = Integer.parseInt(numCols);
         }
         /**
          * Set number of columns
          */
       public void setNumCols( int numCols )
         {
         this.numCols = numCols;
         }
         /**
          * Get list at specified index
          */
       public List getListAt( int index )
         {
         return (List)lists.get(index);
         }
  
         /**
          * Get labels for list at specified index.
          */
       public List getListLabelAt( int index )
         {
         List listLabels = new ArrayList();
         List list = getListAt(index);
  
         Iterator i = list.iterator();
         while(i.hasNext())
           {
           Object key = i.next();
           listLabels.add( getLabel(key) );
           } // end loop
         return listLabels;
         }
  
         /**
          * Add a list without checking
          */
       public void addList( List list )
         {
         lists.add( list);
         }
  
         /**
          * Set list of choices Tiles
          */
       public void setChoices( List list)
         {
         setChoices(list, list);
         }
  
         /**
          * add list to list of choices Tiles
          */
       public void addChoices( List list)
         {
         addChoices( list, list);
         }
  
         /**
          * Set list of choices Tiles
          */
       public void setChoices( List list, List labels)
         {
           // If no labels, use list keys
         if( labels == null )
           labels = list;
           // Check sizes
         if( list.size() != labels.size() )
           {// error
           System.out.println( "Error : list and labels size must be the same." );
           }
         this.choices = list;
         choiceLabels = labels;
         }
  
         /**
          * add list and labels to list of choices Tiles.
          * If labels is null, use keys list as labels.
          * @list list of choice keys to add
          * @labels corresponding labels (list size must be the same as list).
          */
       public void addChoices( List list, List labels)
         {
           // If no labels, use list keys
         if( labels == null )
           labels = list;
           // Check sizes
          if(choices== null)
           {
           setChoices(list, labels);
           return;
           }
  
         if( list.size() != labels.size() )
           {// error
           System.out.println( "Error : list and labels size must be the same." );
           }
         choices.addAll(list);
         choiceLabels.addAll(labels);
         }
  
         /**
          * Get list of choices Tiles
          */
       public List getChoices( )
         {
         return choices;
         }
  
         /**
          * Set labels for choices Tiles.
          */
       public void setChoiceLabels( List list)
         {
         this.choiceLabels = list;
         }
         /**
          * add list to list of choices Tiles
          */
       public void addChoiceLabels( List list)
         {
         if(choiceLabels== null)
           {
           setChoiceLabels(list);
           return;
           }
         choiceLabels.addAll(list);
         }
         /**
          * Get list of choices Tiles
          */
       public List getChoiceLabels( )
         {
         return choiceLabels;
         }
  
         /**
          * Reset list at specified index, and fill it with keys from array.
          * Keys are added only if they are in the choices list.
          * Special keys are transformed in appropriate 'definition'.
          * @index index of the list to add.
          * @keys array of keys to initialize list.
          */
       public void resetListAt( int index, String keys[] )
         {
         List list = getListAt(index);
         list.clear();
         addListAt(index, keys);
         }
         /**
          * Add keys from array to list at specified index.
          * Keys are added only if they are in the choices list.
          * Special keys are transformed in appropriate 'definition'.
          * @index index of the list to add.
          * @keys array of keys to add to list.
          */
       public void addListAt( int index, String keys[] )
         {
           // First, ensure capacity
         while( index>lists.size()-1 ) lists.add(new ArrayList());
  
         List list = getListAt(index);;
           // add keys to list
         for(int i=0;i<keys.length;i++)
           {
           String key = keys[i];
           if( key.indexOf( '@' )>0 )
             { // special key
             }
           if( choices.contains( key ) )
             { // ok, add it
             list.add( key );
             }
           } // end loop
         lists.add( list);
         }
  
     }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dynPortal/PortalPrefsForm.java
  
  Index: PortalPrefsForm.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dynPortal/PortalPrefsForm.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.dynPortal;
  
  import java.util.List;
  import java.util.ArrayList;
  import org.apache.struts.action.ActionForm;
  
  
  /**
   */
  
  public final class PortalPrefsForm extends ActionForm  {
  
      /** Validate value */
    protected String validate;
      /** empty list used by reset */
    protected String[] empty = {};
      /** list of "remaining" choices */
    protected String[] remaining = empty;
      /** list of user columns */
    protected List columns = new ArrayList();
      /** list of user columns labels */
    protected List columnLabels = new ArrayList();
      /** list of columns selected by user */
    protected List newCols = new ArrayList();
  
      /** Choice list */
    protected List choice;
      /** Choice list labels */
    protected List choiceLabels;
      /** Is initialized ? */
    protected boolean initialized = false;
  
  
      /**
       * Set col
       */
    public void setCol( int index, List col )
      {
      columns.set( index, col);
      }
  
      /**
       * Add col
       */
    public void addCol( List col )
      {
      columns.add( col);
      }
  
      /**
       * Get col Labels
       */
    public List getColLabels(int index)
      {
      return (List)columnLabels.get(index);
      }
  
      /**
       * Set col Labels
       */
    public void setColLabels( int index, List col )
      {
      columnLabels.set( index, col);
      }
  
      /**
       * Add col Labels
       */
    public void addColLabels( List col )
      {
      columnLabels.add( col);
      }
  
      /**
       * Get col
       */
    public List getCol(int index)
      {
      return (List)columns.get(index);
      }
  
      /**
       * Set col Labels
       */
    public void setNewCol( int index, String list[] )
      {
        // ensure capacity
      while( index>=newCols.size())newCols.add(null);
      newCols.set( index, list);
      }
  
      /**
       * Get col
       */
    public String[] getNewCol(int index)
      {
      if(newCols==null || index>=newCols.size())
        return null;
      return (String[])newCols.get(index);
      }
  
      /**
       * Get number of columns
       */
    public int getNumCol()
      {
      return newCols.size();
      }
  
      /**
       * Set list1
       */
    public void setL1( String array[] )
      {
      setNewCol(1, array);
      }
      /**
       * Set list1
       */
    public String[] getL1()
      {
      return getNewCol(1);
      }
  
      /**
       * Set list1
       */
    public void setL0( String array[] )
      {
      setNewCol(0, array);
      }
      /**
       * Set list1
       */
    public String[] getL0()
      {
      return getNewCol(0);
      }
      /**
       * Set list1
       */
    public void setRemaining( String array[] )
      {
      remaining = array;
      }
      /**
       * Set list1
       */
    public String[] getRemaining()
      {
      return remaining;
      }
  
  
      /**
       * Set list1
       */
    public void setChoices( List list )
      {
      choice = list;
      }
      /**
       * Set list1
       */
    public void setChoiceLabels( List list )
      {
      choiceLabels = list;
      }
      /**
       * Set list1
       */
    public List getChoices()
      {
      return choice;
      }
      /**
       * Set list1
       */
    public List getChoiceLabels()
      {
      return choiceLabels;
      }
  
     /**
      * Is this form submitted ?
      */
    public boolean isSubmitted()
      {
      return validate != null;
      }
  
     /**
      * Is this form submitted ?
      */
    public void setValidate( String value)
      {
      this.validate = value;
      }
  
      /**
       * Reset properties
       */
    public void reset()
      {
      remaining =  empty;
      validate = null;
      columns.clear();
      columnLabels.clear();
      newCols.clear();
      }
      /**
       * Initialized flag
       */
    public boolean isInitialized()
      {
      return initialized;
      }
      /**
       * Initialized flag
       */
    public void setInitialized( boolean isInitialized)
      {
      initialized = isInitialized;
      }
  }
  
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/lang/SelectLocaleAction.java
  
  Index: SelectLocaleAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/lang/SelectLocaleAction.java,v 1.1 2002/07/11 15:35:20 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:20 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.lang;
  
  import org.apache.struts.taglib.tiles.ComponentConstants;
  
  import java.io.IOException;
  import java.util.Locale;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  public final class SelectLocaleAction extends Action {
  
  
      // --------------------------------------------------------- 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 servlet The ActionServlet making this request
       * @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 {
  
  	// Extract parameters we will need
      String requested = (String)request.getParameter( "language" );
  
      if( requested == null )
   	    return (mapping.findForward("failed"));
      if( requested.equalsIgnoreCase( "FR" ) )
        setLocale( request, Locale.FRANCE );
      if( requested.equalsIgnoreCase( "UK" ) )
        setLocale( request, Locale.UK );
      if( requested.equalsIgnoreCase( "DE" ) )
        setLocale( request, Locale.GERMAN );
  
      //System.out.println( "action perform called" );
        // Fill in nested classes
  	  return (mapping.findForward("success"));
      }
  
      protected void setLocale( HttpServletRequest request, Locale locale )
        {
        HttpSession session = request.getSession(false);
        if (session != null)
          session.setAttribute(ComponentConstants.LOCALE_KEY, locale);
  
        }
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/channel/SelectChannelAction.java
  
  Index: SelectChannelAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/channel/SelectChannelAction.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.channel;
  
  import org.apache.struts.taglib.tiles.ComponentConstants;
  
  import java.io.IOException;
  import java.util.Locale;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  public final class SelectChannelAction extends Action {
  
  
      // --------------------------------------------------------- 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 servlet The ActionServlet making this request
       * @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 {
  
  	// Extract parameters we will need
      String requested = (String)request.getParameter( "channel" );
  
      if( requested == null )
   	    return (mapping.findForward("failed"));
  
        // set in session
      HttpSession session = request.getSession(false);
      if (session != null)
        session.setAttribute(ChannelFactorySet.FACTORY_SELECTOR_KEY, requested);
      System.out.println( "Set channel to '" + requested + "'" );
  	  return (mapping.findForward("success"));
      }
  
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/channel/ChannelFactorySet.java
  
  Index: ChannelFactorySet.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/channel/ChannelFactorySet.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.channel;
  
  import org.apache.struts.tiles.DefinitionsFactoryException;
  import org.apache.struts.tiles.FactoryNotFoundException;
  import org.apache.struts.tiles.DefinitionsUtil;
  import org.apache.struts.tiles.xmlDefinition.*;
  
  import javax.servlet.ServletRequest;
  import javax.servlet.ServletContext;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletRequest;
  
  import java.util.Map;
  import java.util.Locale;
  import java.util.List;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.StringTokenizer;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.FileNotFoundException;
  
  import org.xml.sax.SAXException;
  
  /**
   * Component Definitions factory.
   * This implementation of Component Definitions factory allows i18n
   * Component definitions factory allowing i18n definition.
   * A definition is retrieved by its name, and using locale setted in appropriate session context.
   * Definitions are defined in different files, one for each locale. A definition file is loaded using common name extended with locale code (ex : templateDefinitions_fr.xml). If no file is found under this name, use default file.
  */
  public class ChannelFactorySet extends FactorySet
  {
      /** Debug flag */
    static public final boolean debug = false;
  
      /** Default name */
    public static final String DEFAULT_DEFINITIONS_FILE_NAME = "/WEB-INF/templateDefinitions.xml";
      /** Config file parameter name */
    public static final String DEFINITIONS_CONFIG_PARAMETER_NAME = "definitions-config";
      /** Config file parameter name */
    public static final String FACTORY_SELECTOR_KEY = "ChannelFactorySet.factorySelectorKey";
  
      /** Default factory */
    protected DefinitionsFactory defaultFactory;
      /** Xml parser used */
    protected XmlParser xmlParser;
  
      /** Default filenames extension */
    public static final String FILENAME_EXTENSION = ".xml";
  
      /** Names of default file containing definition descriptions */
    private String filename;
      /** Collection of already loaded definitions set, referenced by their suffix */
    private Map loaded;
  
  
      /**
       * Parameterless Constructor.
       * Method initFactory must be called prior to any use of created factory.
       */
    public ChannelFactorySet()
    {
    }
  
      /**
       * Constructor.
       * Init the factory by reading appropriate configuration file.
       * @throw FactoryNotFoundException Can't find factory configuration file.
       */
    public ChannelFactorySet(ServletContext servletContext, Map properties )
           throws DefinitionsFactoryException
    {
    initFactory( servletContext, properties);
    }
  
      /**
       * Initialization method.
       * Init the factory by reading appropriate configuration file.
       * This method is called exactly once immediately after factory creation in
       * case of internal creation (by DefinitionUtil).
       * @param servletContext Servlet Context passed to newly created factory.
       * @param properties Map of name/property passed to newly created factory. Map can contains
       * more properties than requested.
       * @throws DefinitionsFactoryException An error occur during initialization.
       */
    public void initFactory(ServletContext servletContext, Map properties )
           throws DefinitionsFactoryException
    {
      // read properties values
    String proposedFilename = (String)properties.get(DEFINITIONS_CONFIG_PARAMETER_NAME);
  
      // Compute filenames to use
    boolean isFileSpecified = true;
    if (proposedFilename == null)
      {
      proposedFilename=DEFAULT_DEFINITIONS_FILE_NAME;
      isFileSpecified = false;
      }
  
    try
      {
      initFactory( servletContext, proposedFilename );
      return;
      }
     catch( FileNotFoundException ex )
        {
          // If a filename is specified, throw appropriate error.
        if( isFileSpecified )
          {
          throw new FactoryNotFoundException( ex.getMessage() + " : Can't find file '" +proposedFilename + "'" ) ;
          } // end if
        } // end catch
  
     }
  
      /**
       * Initialization method.
       * Init the factory by reading appropriate configuration file.
       * This method is called exactly once immediately after factory creation in
       * case of internal creation (by DefinitionUtil).
       * @param servletContext Servlet Context passed to newly created factory.
       * @param proposedFilename File names, comma separated, to use as  base file names.
       * @throws DefinitionsFactoryException An error occur during initialization.
       */
    protected void initFactory(ServletContext servletContext, String proposedFilename )
           throws DefinitionsFactoryException, FileNotFoundException
    {
      filename = proposedFilename;
      loaded = new HashMap();
      defaultFactory = createDefaultFactory( servletContext );
    }
  
    /**
     * Get default factory.
     * @return Default factory
     */
    protected DefinitionsFactory getDefaultFactory()
    {
    return defaultFactory;
    }
  
     /**
      * Create default factory .
     * @param servletContext Current servlet context. Used to open file.
     * @return Created default definition factory.
     * @throws DefinitionsFactoryException If an error occur while creating factory.
     * @throws FileNotFoundException if factory can't be loaded from filenames.
      */
    protected DefinitionsFactory createDefaultFactory(ServletContext servletContext)
      throws DefinitionsFactoryException, FileNotFoundException
      {
      XmlDefinitionsSet rootXmlConfig = parseXmlKeyFile( servletContext, "", null );
      if( rootXmlConfig == null )
        throw new FileNotFoundException();
      rootXmlConfig.resolveInheritances();
      return new DefinitionsFactory( rootXmlConfig );
      }
  
    /**
     * Extract key that will be used to get the sub factory.
     * @param name Name of requested definition
     * @param request Current servlet request.
     * @param servletContext Current servlet context
     * @return the key or null if not found.
     * @roseuid 3AF6F887018A
     */
    protected Object getDefinitionsFactoryKey(String name, ServletRequest request, ServletContext servletContext)
    {
    Object key = null;
  
      HttpSession session = ((HttpServletRequest)request).getSession(false);
      if (session != null)
        key = session.getAttribute(FACTORY_SELECTOR_KEY);
  
    return key;
    }
  
     /**
      * Create a factory for specified key.
     * If creation failed, return default factory, and output an error message in
     * console.
     * @param key
     * @return Definition factory for specified key.
     * @throws DefinitionsFactoryException If an error occur while creating factory.
      */
    protected DefinitionsFactory createFactory(Object key, ServletRequest request, ServletContext servletContext)
      throws DefinitionsFactoryException
      {
      if( key == null )
        return getDefaultFactory();
  
        // Already loaded ?
      DefinitionsFactory factory = (DefinitionsFactory)loaded.get( key );
      if( factory != null )
        { // yes, stop loading
        return factory;
        } // end if
          // Try to load file associated to key. If fail, stop and return default factory.
      XmlDefinitionsSet lastXmlFile = parseXmlKeyFile( servletContext, "_" + (String)key, null );
      if( lastXmlFile == null )
        {
        if( DefinitionsUtil.userDebugLevel > DefinitionsUtil.NO_DEBUG )
          System.out.println( "Warning : No definition factory associated to key '"
                                + key + "'. Use default factory instead." );
        factory = getDefaultFactory();
        loaded.put( key, factory );
        return factory;
        } // end if
  
        // Parse default file, and add key file.
      XmlDefinitionsSet rootXmlConfig = parseXmlKeyFile( servletContext, "", null );
  
      rootXmlConfig.extend(lastXmlFile);
      rootXmlConfig.resolveInheritances();
  
      factory = new DefinitionsFactory(rootXmlConfig);
      loaded.put( key, factory );
        // User help
      if( DefinitionsUtil.userDebugLevel > DefinitionsUtil.NO_DEBUG )
        System.out.println( factory );
        // return last available found !
      return factory;
      }
  
      /**
       * Parse files associated to postix if they exist.
       * For each name in filenames, append postfix before file extension,
       * then try to load the corresponding file.
       * If file doesn't exist, try next one. Each file description is added to
       * the XmlDefinitionsSet description.
       * The XmlDefinitionsSet description is created only if there is a definition file.
       * Inheritance is not resolved in the returned XmlDefinitionsSet.
       * If no description file can be opened, and no definiion set is provided, return null.
       * @param postfix Postfix to add to each description file.
       * @param xmlDefinitions Definitions set to which definitions will be added. If null, a definitions
       * set is created on request.
       * @return XmlDefinitionsSet The definitions set created or passed as parameter.
       * @throws DefinitionsFactoryException If an error happen during file parsing.
       */
    private XmlDefinitionsSet parseXmlKeyFile( ServletContext servletContext, String postfix, XmlDefinitionsSet xmlDefinitions )
        throws DefinitionsFactoryException
      {
      if( postfix != null && postfix.length() == 0 )
        postfix = null;
  
      String fullName = concatPostfix( filename, postfix );
      return parseXmlFile( servletContext, fullName, xmlDefinitions);
      }
      /**
       * Parse specified xml file and add definition to specified definitions set.
       * This method is used to load several description files in one instances list.
       * If filename exist and definition set is null, create a new set. Otherwise, return
       * passed definition set (can be null).
       * @param servletContext Current servlet context. Used to open file.
       * @param filename Name of file to parse.
       * @param xmlDefinitions Definitions set to which definitions will be added. If null, a definitions
       * set is created on request.
       * @return XmlDefinitionsSet The definitions set created or passed as parameter.
       * @throws DefinitionsFactoryException If an error happen during file parsing.
       */
    private XmlDefinitionsSet parseXmlFile( ServletContext servletContext, String filename , XmlDefinitionsSet xmlDefinitions)
        throws DefinitionsFactoryException
      {
      try
        {
        if( debug)
          {
          System.out.println( "Try to load '"  + filename + "'.");
          }
  	    InputStream input = servletContext.getResourceAsStream(filename);
  	    if(input == null )
          return xmlDefinitions;
  
          // Create parser
        xmlParser = new XmlParser();
          // Check if definition set already exist.
        if( xmlDefinitions == null )
          {  // create it
          xmlDefinitions = new XmlDefinitionsSet();
          }
  
        xmlParser.parse( input, xmlDefinitions );
  	    }
  	   catch( SAXException ex )
  	    {
        if( debug)
          {
          System.out.println( "Error while parsing file '"  + filename + "'.");
          ex.printStackTrace();
          }
  	    throw new DefinitionsFactoryException( "Error while parsing file '" + filename + "'. " + ex.getMessage(), ex );
  	    }
  	   catch( IOException ex )
  	    {
  	    throw new DefinitionsFactoryException( "IO Error while parsing file '" + filename + "'. " + ex.getMessage(), ex);
  	    }
  
      return xmlDefinitions;
      }
  
      /**
       * Concat postfix to the name. Take care of existing filename extension.
       * Transform the given name "name.ext" to have "name" + "postfix" + "ext".
       * If there is no ext, return "name" + "postfix".
       */
    private String concatPostfix( String name, String postfix )
      {
      if( postfix == null )
        return name;
  
      //postfix = "_" + postfix;
        // Search file name extension.
        // take care of Unix files starting with .
      int dotIndex = name.lastIndexOf( "." );
      int lastNameStart = name.lastIndexOf( java.io.File.pathSeparator );
      if( dotIndex < 1 || dotIndex < lastNameStart )
        return name + postfix;
  
      String ext = name.substring( dotIndex );
      name = name.substring( 0, dotIndex);
      return name + postfix + ext;
      }
  
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/rssChannel/RssChannelsAction.java
  
  Index: RssChannelsAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/rssChannel/RssChannelsAction.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.rssChannel;
  
  import java.io.IOException;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.commons.digester.rss.RSSDigester;
  import org.apache.commons.digester.rss.Channel;
  
  import org.apache.struts.tiles.actions.TilesAction;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionError;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  
  import org.apache.struts.tiles.ComponentContext;
  
  /**
   * Read and parse RSS files found at on a given
   * list in Tile attribute, save the Channel
   * beans in Tile attribute,and forward to "continue".
   * Tiles input attributes :
   * <ul>
   *   <li>urls : list of channel urls</li>
   *   <li>url : a channel url (if urls not use)</li>
   * </ul>
   * Tiles output attributes :
   * <ul>
   *   <li>channels : List of Digester Channel beans</li>
   * </ul>
   *
   * @author Ted Husted
   * @author Cedric Dumoulin
   * @version $Revision: 1.1 $ $Date: 2002/07/11 15:35:21 $
   */
  public final class RssChannelsAction extends TilesAction {
  
  
        /** Debug flag */
      public static final boolean debug = true;
      /**
       * Tile attribute key for saving Channel bean
       */
      public static final String CHANNELS_KEY = "CHANNELS";
      /**
       * Tile attribute key for getting Channel urls list
       */
      public static final String CHANNEL_URLS_KEY = "urls";
      /**
       * Tile attribute key for getting Channel url attribute
       */
      public static final String CHANNEL_URL_KEY = "url";
  
      // --------------------------------------------------------- Instances Variables
      // --------------------------------------------------------- Public Methods
  
      /**
       * Main process of class. Reads, parses
       */
      public ActionForward perform( ComponentContext context,
                                   ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
                            throws IOException, ServletException
      {
      //System.out.println("Enter action UserPortalAction");
      if(debug)
        System.out.println( "Enter Rss Channel Action" );
  
  
          ActionErrors errors = new ActionErrors();
          org.apache.commons.digester.rss.Channel channel = null;
  
          // -- Retrieve parameters --
          // Urls can come from a list, or from a single attribute.
  
          List channels = (List)context.getAttribute( CHANNEL_URLS_KEY );
          if( channels == null )
            {
            Object url = context.getAttribute( CHANNEL_URL_KEY );
            channels = new ArrayList(1);
            channels.add(url);
            }
              //channels.add("http://www.newsforge.com/newsforge.rss");
              //channels.add("http://xmlhack.com/rss.php");
              //channels.add("http://lwn.net/headlines/rss");
          // channels.trimToSize();
  
          if(debug)
            System.out.println( "urls count" + channels.size() ) ;
          // -- Loop through channels --
          List channelBeans = new ArrayList(channels.size());
          try {
              for (int i=0; i<channels.size(); i++) {
                  RSSDigester digester = new RSSDigester();
                  String url = (String)channels.get(i);
                    // Add application path if needed
                  if( url.startsWith("/") )
                    {
                    url = toFullUrl( request, url );
                    }
                  if(debug)  System.out.println( "Channel url=" + url) ;
                  Channel obj = (Channel)digester.parse(url);
                  if(debug)  System.out.println( "Channel:" + obj) ;
                  //System.out.println( "Channel.items:" + obj.getI) ;
                  channelBeans.add(obj);
              }
          }
          catch (Throwable t) {
              errors.add(ActionErrors.GLOBAL_ERROR,
                  new ActionError("rss.access.error"));
              servlet.log(t.toString());
          }
  
          // -- Handle Errors ---
          if (!errors.empty()) {
              saveErrors(request, errors);
              // If no input page, use error forwarding
           if(debug)
             System.out.println( "Exit Rss Channel Action : error" );
              return null; //(mapping.findForward("error"));
          }
  
          // -- Save Bean, and Continue  ---
  
           if(debug)
             System.out.println( "Exit Rss Channel Action" );
            // Use Tile context to pass channels
          context.putAttribute( CHANNELS_KEY,channelBeans);
          return null; //(mapping.findForward("continue"));
      } // ---- End perform ----
  
      /**
       * Compute Full local url from an url starting with "/".
       */
    private String toFullUrl( HttpServletRequest request, String url )
      {
      StringBuffer buff = new StringBuffer();
  
      buff.append( request.getScheme() ) .append( "://" ) . append(request.getServerName());
      if( request.getServerPort() != 80 )
        buff.append( ":" ).append( request.getServerPort() );
      buff.append( request.getContextPath()).append( url);
      return buff.toString();
      }
  
  } // ---- End Fetch ----
  
  
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/rssChannel/RssChannelsAction.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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 apache@apache.org.
   *
   * 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/>.
   *
   */
  
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/rssChannel/Channels.java
  
  Index: Channels.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/rssChannel/Channels.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.rssChannel;
  
  import java.io.IOException;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  //import org.apache.portlet.PortletDataHashMap;
  
  import org.apache.commons.digester.rss.RSSDigester;
  import org.apache.commons.digester.rss.Channel;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionError;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  
  import org.apache.struts.tiles.ComponentContext;
  
  /**
   * Read and parse RSS files found at on a given
   * list in user request or session, save the Channel
   * beans in request scope,and forward to "continue".
   * @expects path={uri} on command line or as parameter property to ActionMapping.
   * @expects an input page or error forwarding if exception digesting RSS
   * @author Ted Husted
   * @author Cedric Dumoulin
   * @version $Revision: 1.1 $ $Date: 2002/07/11 15:35:21 $
   */
  public final class Channels extends Action {
  
  
        /** Debug flag */
      public static final boolean debug = true;
      /**
       * Tile attribute key for saving Channel bean
       */
      public static final String CHANNELS_KEY = "CHANNELS";
      /**
       * Tile attribute key for getting Channel urls list
       */
      public static final String CHANNEL_URLS_KEY = "urls";
      /**
       * Tile attribute key for getting Channel url attribute
       */
      public static final String CHANNEL_URL_KEY = "url";
  
      // --------------------------------------------------------- Instances Variables
      // --------------------------------------------------------- Public Methods
  
      /**
       * Main process of class. Reads, parses
       */
      public ActionForward perform(ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)
          throws IOException, ServletException {
  
      if(debug)
        System.out.println( "Enter Rss Channel Action" );
  
            // Try to retrieve tile context
      ComponentContext context = ComponentContext.getContext( request );
      if( context == null )
        {
        throw new ServletException( "This action must be called by a Tile, not directly" );
        }
  
          ActionErrors errors = new ActionErrors();
          org.apache.commons.digester.rss.Channel channel = null;
  
          // -- Retrieve parameters --
          // Urls can come from a list, or from a single attribute.
  
          List channels = (List)context.getAttribute( CHANNEL_URLS_KEY );
          if( channels == null )
            {
            Object url = context.getAttribute( CHANNEL_URL_KEY );
            channels = new ArrayList(1);
            channels.add(url);
            }
              //channels.add("http://www.newsforge.com/newsforge.rss");
              //channels.add("http://xmlhack.com/rss.php");
              //channels.add("http://lwn.net/headlines/rss");
          // channels.trimToSize();
  
          if(debug)
            System.out.println( "urls count" + channels.size() ) ;
          // -- Loop through channels --
          ArrayList channelBeans = new ArrayList(channels.size());
          try {
              for (int i=0; i<channels.size(); i++) {
                  RSSDigester digester = new RSSDigester();
                  String url = (String)channels.get(i);
                    // Add application path if needed
                  if( url.startsWith("/") )
                    {
                    url = toFullUrl( request, url );
                    }
                  if(debug)  System.out.println( "Channel url=" + url) ;
                  Channel obj = (Channel)digester.parse(url);
                  if(debug)  System.out.println( "Channel:" + obj) ;
                  //System.out.println( "Channel.items:" + obj.getI) ;
                  channelBeans.add(obj);
              }
          }
          catch (Throwable t) {
              errors.add(ActionErrors.GLOBAL_ERROR,
                  new ActionError("rss.access.error"));
              servlet.log(t.toString());
          }
  
          // -- Handle Errors ---
          if (!errors.empty()) {
              saveErrors(request, errors);
              if (mapping.getInput()!=null)
                  return (new ActionForward(mapping.getInput()));
              // If no input page, use error forwarding
           if(debug)
             System.out.println( "Exit Rss Channel Action : error" );
              return (mapping.findForward("error"));
          }
  
          // -- Save Bean, and Continue  ---
  
           if(debug)
             System.out.println( "Exit Rss Channel Action" );
          //request.setAttribute(CHANNELS_KEY,channelBeans);
            // Use Tile context to pass channels
          context.putAttribute( CHANNELS_KEY,channelBeans);
          return (mapping.findForward("continue"));
      } // ---- End perform ----
  
    private String toFullUrl( HttpServletRequest request, String url )
      {
      StringBuffer buff = new StringBuffer();
  
      buff.append( request.getScheme() ) .append( "://" ) . append(request.getServerName());
      if( request.getServerPort() != 80 )
        buff.append( ":" ).append( request.getServerPort() );
      buff.append( request.getContextPath()).append( url);
      return buff.toString();
      }
  
  } // ---- End Fetch ----
  
  
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/rssChannel/Channels.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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 apache@apache.org.
   *
   * 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/>.
   *
   */
  
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/invoice/InvoiceForm.java
  
  Index: InvoiceForm.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/invoice/InvoiceForm.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.invoice;
  
  import java.util.Vector;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  
  
  /**
   */
  
  public final class InvoiceForm extends ActionForm {
  
    /**
     * Shipping address
     */
    private Address shippingAddress;
  
    /**
     * Bill address
     */
    private Address billAddress;
  
    /**
     * Invoice total amount
     */
    private double amount;
  
    /**
     * Customer firstname
     */
    private String firstname;
  
    /**
     * Customer last name
     */
    private String lastname;
  
    public InvoiceForm()
      {
      shippingAddress = new Address();
      billAddress = new Address();
      }
  
    /**
     * Access method for the shippingAddress property.
     *
     * @return   the current value of the shippingAddress property
     */
    public Address getShippingAddress()
     {
      return shippingAddress;}
  
    /**
     * @return void
     * Sets the value of the shippingAddress property.
     *
     * @param aShippingAddress the new value of the shippingAddress property
     */
    public void setShippingAddress(Address aShippingAddress)
      {
      shippingAddress = aShippingAddress;
      }
  
    /**
     * Access method for the billAddress property.
     *
     * @return   the current value of the billAddress property
     */
    public Address getBillAddress()
      {
      return billAddress;
      }
  
    /**
     * @return void
     * Sets the value of the billAddress property.
     *
     * @param aBillAddress the new value of the billAddress property
     */
    public void setBillAddress(Address aBillAddress)
      {
      billAddress = aBillAddress;
      }
  
    /**
     * Access method for the amount property.
     *
     * @return   the current value of the amount property
     */
    public double getAmount()
      {
      return amount;
      }
  
    /**
     * @return void
     * Sets the value of the amount property.
     *
     * @param aAmount the new value of the amount property
     */
    public void setAmount(double aAmount)
      {
      amount = aAmount;
      }
  
    /**
     * Access method for the firstname property.
     *
     * @return   the current value of the firstname property
     */
    public String getFirstname()
      {
      return firstname;
      }
  
    /**
     * @return void
     * Sets the value of the firstname property.
     *
     * @param aFirstname the new value of the firstname property
     */
    public void setFirstname(String aFirstname)
      {
      firstname = aFirstname;
      }
  
    /**
     * Access method for the lastname property.
     *
     * @return   the current value of the lastname property
     */
    public String getLastname()
      {
      return lastname;
      }
  
    /**
     * @return void
     * Sets the value of the lastname property.
     *
     * @param aLastname the new value of the lastname property
     */
    public void setLastname(String aLastname)
      {
      lastname = aLastname;
      }
  
  }
  
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/invoice/Invoice.java
  
  Index: Invoice.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/invoice/Invoice.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.invoice;
  
  import org.apache.struts.action.ActionForm;
  
  /**
   * An invoice.
   */
  public class Invoice extends ActionForm
  {
  
    /**
     * Shipping address
     */
    private Address shippingAddress;
  
    /**
     * Bill address
     */
    private Address billAddress;
  
    /**
     * Invoice total amount
     */
    private double amount;
  
    /**
     * Customer firstname
     */
    private String firstname;
  
    /**
     * Customer last name
     */
    private String lastname;
  
    public Invoice()
      {
      shippingAddress = new Address();
      billAddress = new Address();
      }
  
    /**
  * Access method for the shippingAddress property.
  *
  * @return   the current value of the shippingAddress property
     */
    public Address getShippingAddress() {
      return shippingAddress;}
  
    /**
     * @return void
  * Sets the value of the shippingAddress property.
  *
  * @param aShippingAddress the new value of the shippingAddress property
     */
    public void setShippingAddress(Address aShippingAddress) {
      shippingAddress = aShippingAddress;}
  
    /**
  * Access method for the billAddress property.
  *
  * @return   the current value of the billAddress property
     */
    public Address getBillAddress() {
      return billAddress;}
  
    /**
     * @return void
  * Sets the value of the billAddress property.
  *
  * @param aBillAddress the new value of the billAddress property
     */
    public void setBillAddress(Address aBillAddress) {
      billAddress = aBillAddress;}
  
    /**
  * Access method for the amount property.
  *
  * @return   the current value of the amount property
     */
    public double getAmount() {
      return amount;}
  
    /**
     * @return void
  * Sets the value of the amount property.
  *
  * @param aAmount the new value of the amount property
     */
    public void setAmount(double aAmount) {
      amount = aAmount;}
  
    /**
  * Access method for the firstname property.
  *
  * @return   the current value of the firstname property
     */
    public String getFirstname() {
      return firstname;}
  
    /**
     * @return void
  * Sets the value of the firstname property.
  *
  * @param aFirstname the new value of the firstname property
     */
    public void setFirstname(String aFirstname) {
      firstname = aFirstname;}
  
    /**
  * Access method for the lastname property.
  *
  * @return   the current value of the lastname property
     */
    public String getLastname() {
      return lastname;}
  
    /**
     * @return void
  * Sets the value of the lastname property.
  *
  * @param aLastname the new value of the lastname property
     */
    public void setLastname(String aLastname) {
      lastname = aLastname;}
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/invoice/EditInvoiceAction.java
  
  Index: EditInvoiceAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/invoice/EditInvoiceAction.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.invoice;
  
  import java.io.IOException;
  import java.util.Locale;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  import org.apache.struts.util.RequestUtils;
  
  
  /**
   * Implementation of <strong>Action</strong> that populates an instance of
   * <code>SubscriptionForm</code> from the currently specified subscription.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/07/11 15:35:21 $
   */
  
  public final class EditInvoiceAction extends Action {
  
  
      // --------------------------------------------------------- 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 servlet The ActionServlet making this request
       * @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 {
  
  	// Extract attributes we will need
  	Locale locale = getLocale(request);
  	HttpSession session = request.getSession();
  
      //System.out.println( "action perform called" );
        // Fill in nested classes
      InvoiceForm invoice = (InvoiceForm)form;
  
      //RequestUtils.populate(  invoice.getBillAddress(), "billAddress.", null, request );
      //RequestUtils.populate(  invoice.getShippingAddress(), "shippingAddress.", null, request );
  	  return (mapping.findForward("success"));
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/invoice/Address.java
  
  Index: Address.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/invoice/Address.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.invoice;
  
  /**
   * An address.
   */
  public class Address
  {
  
    /**
     * Street part 1
     */
    private String street1;
  
    /**
     * Street part 2
     */
    private String street2;
  
    /**
     * City
     */
    private String city;
  
    /**
     * Country
     */
    private String country;
  
    /**
     * Zip Code
     */
    private String zipCode;
  
    public Address()
    {
    }
  
    /**
  * Access method for the street1 property.
  *
  * @return   the current value of the street1 property
     */
    public String getStreet1() {
      return street1;}
  
    /**
     * @return void
  * Sets the value of the street1 property.
  *
  * @param aStreet1 the new value of the street1 property
     */
    public void setStreet1(String aStreet1) {
      street1 = aStreet1;}
  
    /**
  * Access method for the street2 property.
  *
  * @return   the current value of the street2 property
     */
    public String getStreet2() {
      return street2;}
  
    /**
     * @return void
  * Sets the value of the street2 property.
  *
  * @param aStreet2 the new value of the street2 property
     */
    public void setStreet2(String aStreet2) {
      street2 = aStreet2;}
  
    /**
  * Access method for the city property.
  *
  * @return   the current value of the city property
     */
    public String getCity() {
      return city;}
  
    /**
     * @return void
  * Sets the value of the city property.
  *
  * @param aCity the new value of the city property
     */
    public void setCity(String aCity) {
      city = aCity;}
  
    /**
  * Access method for the country property.
  *
  * @return   the current value of the country property
     */
    public String getCountry() {
      return country;}
  
    /**
     * @return void
  * Sets the value of the country property.
  *
  * @param aCountry the new value of the country property
     */
    public void setCountry(String aCountry) {
      country = aCountry;}
  
    /**
  * Access method for the zipCode property.
  *
  * @return   the current value of the zipCode property
     */
    public String getZipCode() {
      return zipCode;}
  
    /**
     * @return void
  * Sets the value of the zipCode property.
  *
  * @param aZipCode the new value of the zipCode property
     */
    public void setZipCode(String aZipCode) {
      zipCode = aZipCode;}
  }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/tutorial/ForwardExampleAction.java
  
  Index: ForwardExampleAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/tutorial/ForwardExampleAction.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.tutorial;
  
  import java.io.IOException;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  public class ForwardExampleAction extends Action {
  
      /**
       * 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 servlet The ActionServlet making this request
       * @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
      {
      String success = request.getParameter( "success" );
      if( success != null )
  	    return (mapping.findForward("success"));
  
      return (mapping.findForward("failure"));
      }
  
   }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/template/DynTemplateAction.java
  
  Index: DynTemplateAction.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/template/DynTemplateAction.java,v 1.1 2002/07/11 15:35:21 cedric Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/11 15:35:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Struts", 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 apache@apache.org.
   *
   * 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.struts.webapp.tiles.template;
  
  import org.apache.struts.tiles.ComponentDefinition;
  
  import java.io.IOException;
  import java.util.Locale;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  import org.apache.struts.util.MessageResources;
  
  
  public final class DynTemplateAction extends Action {
  
  
      // --------------------------------------------------------- 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 servlet The ActionServlet making this request
       * @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 {
  
      System.out.println( "Start dynamic definition" );
        // Create template definition
      ComponentDefinition definition = new ComponentDefinition();
      String path = "/tutorial";
        // set definition 'contents'
      //definition.setTemplate( "/tutorial/basic/myFramesetLayout.jsp" );
      definition.put( "title", "My first dynamic frameset page", true );
        // using type="string" is the same as direct=true
      definition.put( "header", path + "/common/header.jsp", "string", null );
      definition.put( "footer", path + "/common/footer.jsp", true );
      definition.put( "menu", path + "/basic/menu.jsp", true );
      definition.put( "body", path + "/basic/helloBody.jsp", true );
  
      System.out.println( "definition=" + definition );
        // Save our definition as a bean :
      request.setAttribute( "templateDefinition", definition );
  
  	  return (mapping.findForward("success"));
      }
  
   }
  
  
  
  1.1                  jakarta-struts/src/tiles-documentation/org/apache/struts/webapp/tiles/dev1-1/ApplicationResources.properties
  
  Index: ApplicationResources.properties
  ===================================================================
  button.cancel=Cancel
  button.confirm=Confirm
  button.reset=Reset
  button.save=Save
  change.message=Your password has expired.  Please ask the system administrator to change it.
  change.try=Try Again
  change.title=Password Has Expired
  database.load=Cannot load database from {0}
  error.database.missing=<li>User database is missing, cannot validate logon credentials</li>
  error.fromAddress.format=<li>Invalid format for From Address</li>
  error.fromAddress.required=<li>From Address is required</li>
  error.fullName.required=<li>Full Name is required</li>
  error.host.required=<li>Mail Server is required</li>
  error.noSubscription=<li>No Subscription bean in user session</li>
  error.password.required=<li>Password is required</li>
  error.password2.required=<li>Confirmation password is required</li>
  error.password.match=<li>Password and confirmation password must match</li>
  error.password.mismatch=<li>Invalid username and/or password, please try again</li>
  error.replyToAddress.format=<li>Invalid format for Reply To Address</li>
  error.transaction.token=<li>Cannot submit this form out of order</li>
  error.type.invalid=<li>Server Type must be 'imap' or 'pop3'</li>
  error.type.required=<li>Server Type is required</li>
  error.username.required=<li>Username is required</li>
  error.username.unique=<li>That username is already in use - please select another</li>
  errors.footer=</ul><hr>
  errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul>
  errors.ioException=I/O exception rendering error messages: {0}
  heading.autoConnect=Auto
  heading.subscriptions=Current Subscriptions
  heading.host=Host Name
  heading.user=User Name
  heading.type=Server Type
  heading.action=Action
  index.heading=MailReader Demonstration Application Options
  index.logon=Log on to the MailReader Demonstration Application
  index.registration=Register with the MailReader Demonstration Application
  index.title=MailReader Demonstration Application (Struts 1.1-dev)
  index.tour=A Walking Tour of the Example Application
  linkSubscription.io=I/O Error: {0}
  linkSubscription.noSubscription=No subscription under attribute {0}
  linkUser.io=I/O Error: {0}
  linkUser.noUser=No user under attribute {0}
  logon.title=MailReader Demonstration Application - Logon
  mainMenu.heading=Main Menu Options for 
  mainMenu.logoff=Log off MailReader Demonstration Application
  mainMenu.registration=Edit your user registration profile
  mainMenu.title=MailReader Demonstration Application - Main Menu
  option.imap=IMAP Protocol
  option.pop3=POP3 Protocol
  prompt.autoConnect=Auto Connect:
  prompt.fromAddress=From Address:
  prompt.fullName=Full Name:
  prompt.mailHostname=Mail Server:
  prompt.mailPassword=Mail Password:
  prompt.mailServerType=Server Type:
  prompt.mailUsername=Mail Username:
  prompt.password=Password:
  prompt.password2=(Repeat) Password:
  prompt.replyToAddress=Reply To Address:
  prompt.username=Username:
  registration.addSubscription=Add
  registration.deleteSubscription=Delete
  registration.editSubscription=Edit
  registration.title.create=Register for the MailReader Demostration Application
  registration.title.edit=Edit Registration for the MailReader Demonstration Application
  subscription.title.create=Create New Mail Subscription
  subscription.title.delete=Delete Existing Mail Subscription
  subscription.title.edit=Edit Existing Mail Subscription
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>