View Javadoc

    1   /*
    2    * $Id: SelectInclude.java 471754 2006-11-06 14:55:09Z husted $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *  http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    20   */
    21  package org.apache.struts.chain.commands;
    22
    23  import org.apache.commons.logging.Log;
    24  import org.apache.commons.logging.LogFactory;
    25  import org.apache.struts.chain.contexts.ActionContext;
    26  import org.apache.struts.config.ActionConfig;
    27
    28  /**
    29   * <p>Select and cache the include for this <code>ActionConfig</code> if
    30   * specified.</p>
    31   *
    32   * @version $Rev: 471754 $ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
    33   *          $
    34   */
    35  public class SelectInclude extends ActionCommandBase {
    36      // ------------------------------------------------------ Instance Variables
    37
    38      /**
    39       * <p> Provide Commons Logging instance for this class. </p>
    40       */
    41      private static final Log LOG = LogFactory.getLog(SelectInclude.class);
    42
    43      // ---------------------------------------------------------- Public Methods
    44
    45      /**
    46       * <p>Select and cache the include uri for this <code>ActionConfig</code>
    47       * if specified.</p>
    48       *
    49       * @param actionCtx The <code>Context</code> for the current request
    50       * @return <code>false</code> so that processing continues
    51       * @throws Exception on any error
    52       */
    53      public boolean execute(ActionContext actionCtx)
    54          throws Exception {
    55          // Acquire configuration objects that we need
    56          ActionConfig actionConfig = actionCtx.getActionConfig();
    57
    58          // Cache an include uri if found
    59          String include = actionConfig.getInclude();
    60
    61          if (include != null) {
    62              if (LOG.isDebugEnabled()) {
    63                  LOG.debug("Including " + include);
    64              }
    65
    66              actionCtx.setInclude(include);
    67          }
    68
    69          return (false);
    70      }
    71  }