cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From froehl...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/acting SetCharacterEncodingAction.java
Date Wed, 13 Feb 2002 09:37:59 GMT
froehlich    02/02/13 01:37:59

  Added:       src/java/org/apache/cocoon/acting
                        SetCharacterEncodingAction.java
  Log:
  applied patch from  MIYABE Tatsuhiko [miyabe@jzf.co.jp].
  Form encoding enhancement!
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/java/org/apache/cocoon/acting/SetCharacterEncodingAction.java
  
  Index: SetCharacterEncodingAction.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.cocoon.acting;
  
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.cocoon.Constants;
  import org.apache.cocoon.environment.Request;
  import org.apache.cocoon.environment.Redirector;
  import org.apache.cocoon.environment.SourceResolver;
  
  import java.util.Map;
  
  /**
   * Sets the character encoding of parameters.
   * Components use this encoding as default after the action.
   * <p>
   * <b>Configuration options:</b>
   * <dl>
   * <dt> <i>form-encoding</i> (required)
   * <dd> The supposed encoding of the request parameter.
   * <dt> <i>form-encoding</i> (optional)
   * </dl>
   * These configuration options supported in both declaration and use time.
   *
   * @author <a href="mailto:miyabe@jzf.co.jp">MIYABE Tatsuhiko</a>
   */
  public class SetCharacterEncodingAction extends ComposerAction implements ThreadSafe, Parameterizable
{
      private String global_form_encoding = null;
  
      public void parameterize(Parameters parameters)
      throws ParameterException {
          // super.parameterize(parameters);
  
          global_form_encoding = parameters.getParameter("form-encoding", null);
      }
  
      /**
       * Set character encoding of current request.
       */
      public Map act (Redirector redirector, SourceResolver resolver, Map objectModel, String
src, Parameters par) throws Exception {
          Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
          if (request != null) {
              String form_encoding = par.getParameter("form-encoding", global_form_encoding);
              if (form_encoding != null) {
                  request.setCharacterEncoding(form_encoding);
              }
          }
  
          return null;
      }
  }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message