mman        01/10/23 02:58:19

  Modified:    src/org/apache/cocoon/components/language/markup/xsp Tag:
                        cocoon_20_branch XSPRequestHelper.java
               src/org/apache/cocoon/components/language/markup/xsp/java
                        Tag: cocoon_20_branch request.xsl
  Log:
  added attribute `as' to <xsp-request:get-parameter-values>, supported output is
  'xml' and 'array'
  Closes #4364
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.8   +38 -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.5.2.7
  retrieving revision 1.5.2.8
  diff -u -r1.5.2.7 -r1.5.2.8
  --- XSPRequestHelper.java     2001/10/19 20:42:59     1.5.2.7
  +++ XSPRequestHelper.java     2001/10/23 09:58:19     1.5.2.8
  @@ -23,7 +23,7 @@
    * The <code>Request</code> object helper
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Ricardo Rocha</a>
  - * @version CVS $Revision: 1.5.2.7 $ $Date: 2001/10/19 20:42:59 $
  + * @version CVS $Revision: 1.5.2.8 $ $Date: 2001/10/23 09:58:19 $
    */
   public class XSPRequestHelper {
     /**
  @@ -298,6 +298,43 @@
         }
   
         XSPObjectHelper.end(URI, PREFIX, contentHandler, "parameter-values");
  +    }
  +
  +  /**
  +   * return the request parameter values for a given name as array
  +   *
  +   * @param objectModel The Map objectModel
  +   * @param contentHandler The SAX content handler
  +   * @param form_encoding The supposed encoding of the request parameter.
  +   * @param container_encoding The encoding used by container.
  +   * @return Array containing requested values.
  +   */
  +  public static String[] getParameterValues(
  +      Map objectModel,
  +      String name,
  +      String form_encoding,
  +      String container_encoding
  +      )
  +    {
  +      Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
  +
  +      String[] values = request.getParameterValues(name);
  +
  +      if (values != null) {
  +        for (int i = 0; i < values.length; i++) {
  +          if(form_encoding != null && values[i] != null && 
  +              values[i].length() > 0) {
  +            try {
  +              values[i] = new String(values[i].getBytes(container_encoding), 
  +                  form_encoding);
  +            } catch(java.io.UnsupportedEncodingException uee) {
  +              throw new RuntimeException("Unsupported Encoding Exception: " +
  +                  uee.getMessage());
  +            }
  +          }
  +        }
  +      }
  +      return values;
       }
   
     /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.4   +27 -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.3.2.3
  retrieving revision 1.3.2.4
  diff -u -r1.3.2.3 -r1.3.2.4
  --- request.xsl       2001/10/19 20:43:00     1.3.2.3
  +++ request.xsl       2001/10/23 09:58:19     1.3.2.4
  @@ -11,7 +11,7 @@
   
   <!--
    * @author <a href="mailto:[EMAIL PROTECTED]>Ricardo Rocha</a>
  - * @version CVS $Revision: 1.3.2.3 $ $Date: 2001/10/19 20:43:00 $
  + * @version CVS $Revision: 1.3.2.4 $ $Date: 2001/10/23 09:58:19 $
   -->
   
   <!-- XSP Request logicsheet for the Java language -->
  @@ -186,6 +186,13 @@
   
     <!-- emitting output as xml only -->
     <xsl:template match="xsp-request:get-parameter-values">
  +
  +    <xsl:variable name="as">
  +      <xsl:call-template name="value-for-as">
  +        <xsl:with-param name="default" select="'xml'"/>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
       <xsl:variable name="name">
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
  @@ -198,12 +205,25 @@
         <xsl:call-template name="value-for-container-encoding"/>
       </xsl:variable>
   
  -    <xsp:logic>
  -      XSPRequestHelper.getParameterValues(objectModel, this.contentHandler,
  -      <xsl:copy-of select="$name"/>, 
  -      <xsl:copy-of select="$form-encoding"/>, 
  -      <xsl:copy-of select="$container-encoding"/>);
  -    </xsp:logic>
  +    <xsl:choose>
  +      <xsl:when test="$as = 'array'">
  +        <xsp:expr>
  +          (XSPRequestHelper.getParameterValues(objectModel, 
  +          <xsl:copy-of select="$name"/>, 
  +          <xsl:copy-of select="$form-encoding"/>, 
  +          <xsl:copy-of select="$container-encoding"/>))
  +        </xsp:expr>
  +      </xsl:when>
  +      <xsl:when test="$as = 'xml'">
  +        <!-- <xsp-request:parameter-values name="..."> -->
  +        <xsp:logic>
  +          XSPRequestHelper.getParameterValues(objectModel, this.contentHandler,
  +          <xsl:copy-of select="$name"/>, 
  +          <xsl:copy-of select="$form-encoding"/>, 
  +          <xsl:copy-of select="$container-encoding"/>);
  +        </xsp:logic>
  +      </xsl:when>
  +    </xsl:choose>
     </xsl:template>
   
     <!-- emitting output as xml only -->
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to