cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/java request.xsl
Date Tue, 16 Oct 2001 09:38:08 GMT
mman        01/10/16 02:38:08

  Modified:    documentation/xdocs request.xml
               src/org/apache/cocoon/components/language/markup/xsp
                        XSPRequestHelper.java
               src/org/apache/cocoon/components/language/markup/xsp/java
                        request.xsl
  Log:
  Patch from  Enke Michael <Michael.Enke@wincor-nixdorf.com>, for "encoding for requests"
  - it adds two attributes to <xsp-request:get-parameter called
  	form-encoding (indicates in which encoding the form data came)
  	container-encoding (which encoding the container uses, iso1 by default)
  
  note that I've not patched 2.0 branch, since these attributes should probably
  be supported in <xsp-request:get-parameter-values> also...
  
  Revision  Changes    Path
  1.2       +4 -1      xml-cocoon2/documentation/xdocs/request.xml
  
  Index: request.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/documentation/xdocs/request.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- request.xml	2001/09/28 13:41:29	1.1
  +++ request.xml	2001/10/16 09:38:08	1.2
  @@ -336,7 +336,10 @@
   <td>Gets the value of the named request parameter.  This is a value from
   the request string (e.g., ?fruit=apple) or from POSTed form data.  If the parameter
   has more than one value, (e.g, ?fruit=apple&amp;fruit=orange), then this gets the first
  -value.  See xsp-request:get-parameter-values.</td>
  +value.  See xsp-request:get-parameter-values. Possible attributes:
  +form-encoding (depends on the encoding of the page which sends the form data)
  +and container-encoding (default per servlet spec: ISO-8859-1 but if your servlet container
  +uses another one you can adjust)</td>
   </tr>
   
   <tr>
  
  
  
  1.12      +22 -1     xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPRequestHelper.java
  
  Index: XSPRequestHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPRequestHelper.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XSPRequestHelper.java	2001/10/11 07:20:26	1.11
  +++ XSPRequestHelper.java	2001/10/16 09:38:08	1.12
  @@ -23,7 +23,7 @@
    * The <code>Request</code> object helper
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.11 $ $Date: 2001/10/11 07:20:26 $
  + * @version CVS $Revision: 1.12 $ $Date: 2001/10/16 09:38:08 $
    */
   public class XSPRequestHelper {
     /**
  @@ -104,13 +104,34 @@
      * @param name The parameter name
      * @param defaultValue Value to substitute in absence of a parameter value
      */
  +
     public static String getParameter(
       Map objectModel,
       String name,
       String defaultValue
     ) {
  +    return getParameter(objectModel, name, defaultValue, null, null);
  +  }
  +
  +  public static String getParameter(
  +    Map objectModel,
  +    String name,
  +    String defaultValue,
  +    String form_encoding,
  +    String container_encoding
  +  ) {
  +    if(container_encoding == null) container_encoding = "ISO-8859-1"; // default per JSP
spec
       Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
       String value = request.getParameter(name);
  +    if(form_encoding != null && value != null && value.length() > 0)
{
  +      try {
  +        value = new String(value.getBytes(container_encoding), form_encoding);
  +      }
  +      catch(java.io.UnsupportedEncodingException uee) {
  +        throw new RuntimeException("Unsupported Encoding Exception: " +
  +                                    uee.getMessage());
  +      }
  +    }
   
       if (value == null) {
         value = defaultValue;
  
  
  
  1.6       +35 -7     xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/java/request.xsl
  
  Index: request.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/java/request.xsl,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- request.xsl	2001/09/19 16:07:58	1.5
  +++ request.xsl	2001/10/16 09:38:08	1.6
  @@ -11,7 +11,7 @@
   
   <!--
    * @author <a href="mailto:ricardo@apache.org>Ricardo Rocha</a>
  - * @version CVS $Revision: 1.5 $ $Date: 2001/09/19 16:07:58 $
  + * @version CVS $Revision: 1.6 $ $Date: 2001/10/16 09:38:08 $
   -->
   
   <!-- XSP Request logicsheet for the Java language -->
  @@ -126,6 +126,33 @@
         </xsl:choose>
       </xsl:variable>
   
  +    <xsl:variable name="form-encoding">
  +      <xsl:choose>
  +        <xsl:when test="@form-encoding">"<xsl:value-of 
  +            select="@form-encoding"/>"</xsl:when>
  +        <xsl:when test="form-encoding">
  +          <xsl:call-template name="get-nested-content">
  +            <xsl:with-param name="content" select="xsp-request:form-encoding"/>
  +          </xsl:call-template>
  +        </xsl:when>
  +        <xsl:otherwise>null</xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +
  +    <xsl:variable name="container-encoding">
  +      <xsl:choose>
  +        <xsl:when test="@container-encoding">"<xsl:value-of 
  +            select="@container-encoding"/>"</xsl:when>
  +        <xsl:when test="container-encoding">
  +          <xsl:call-template name="get-nested-content">
  +            <xsl:with-param name="content" 
  +              select="xsp-request:container-encoding"/>
  +          </xsl:call-template>
  +        </xsl:when>
  +        <xsl:otherwise>null</xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +
       <xsl:variable name="as">
         <xsl:call-template name="value-for-as">
           <xsl:with-param name="default" select="'string'"/>
  @@ -135,13 +162,13 @@
       <xsl:choose>
         <xsl:when test="$as = 'string'">
           <xsp:expr>
  -          (XSPRequestHelper.getParameter(objectModel, <xsl:copy-of select="$name"/>,
<xsl:copy-of select="$default"/>))
  +          (XSPRequestHelper.getParameter(objectModel, <xsl:copy-of select="$name"/>,
<xsl:copy-of select="$default"/>, <xsl:copy-of select="$form-encoding"/>, <xsl:copy-of
select="$container-encoding"/>))
           </xsp:expr>
         </xsl:when>
         <xsl:when test="$as = 'xml'">
       <!-- <xsp-request:uri> -->
           <xsp:logic>
  -          XSPRequestHelper.getParameter(objectModel, this.contentHandler, <xsl:copy-of
select="$name"/>, <xsl:copy-of select="$default"/>);
  +          XSPRequestHelper.getParameter(objectModel, this.contentHandler, <xsl:copy-of
select="$name"/>, <xsl:copy-of select="$default"/>, <xsl:copy-of select="$form-encoding"/>,
<xsl:copy-of select="$container-encoding"/>);
           </xsp:logic>
         </xsl:when>
       </xsl:choose>
  @@ -226,10 +253,11 @@
         </xsl:when>
       </xsl:choose>
     </xsl:template>
  -	<xsl:template match="xsp-request:get-attribute-names">
  -     <xsp:logic>
  -        XSPRequestHelper.getAttributeNames(objectModel, this.contentHandler);
  -     </xsp:logic>
  +  
  +  <xsl:template match="xsp-request:get-attribute-names">
  +    <xsp:logic>
  +      XSPRequestHelper.getAttributeNames(objectModel, this.contentHandler);
  +    </xsp:logic>
     </xsl:template>
   	
     <xsl:template match="xsp-request:remove-attribute">
  
  
  

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