mman 01/10/23 02:59:10
Modified: src/org/apache/cocoon/components/language/markup/xsp
XSPRequestHelper.java
src/org/apache/cocoon/components/language/markup/xsp/java
request.xsl
Log:
added attribute `as' to <xsp-request:get-parameter-values>, supported output is
'xml' and 'array'
Closes #4364
Revision Changes Path
1.15 +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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XSPRequestHelper.java 2001/10/19 20:44:07 1.14
+++ XSPRequestHelper.java 2001/10/23 09:59:10 1.15
@@ -23,7 +23,7 @@
* The <code>Request</code> object helper
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
- * @version CVS $Revision: 1.14 $ $Date: 2001/10/19 20:44:07 $
+ * @version CVS $Revision: 1.15 $ $Date: 2001/10/23 09:59:10 $
*/
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;
}
/**
1.9 +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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- request.xsl 2001/10/19 20:44:07 1.8
+++ request.xsl 2001/10/23 09:59:10 1.9
@@ -11,7 +11,7 @@
<!--
* @author <a href="mailto:[EMAIL PROTECTED]>Ricardo Rocha</a>
- * @version CVS $Revision: 1.8 $ $Date: 2001/10/19 20:44:07 $
+ * @version CVS $Revision: 1.9 $ $Date: 2001/10/23 09:59:10 $
-->
<!-- 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]