cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Per Kreipke" <...@onclave.com>
Subject Request taglib...
Date Thu, 21 Sep 2000 16:08:17 GMT
Attached is some code to add missing functionality to the request taglib in
XSPRequestLibrary.java. It includes the following to return a node set of
all parameters.

public static Element getAllParameterValues(
	HttpServletRequest request,
	Document document
	) {
	String[] parameterNames = XSPRequestLibrary.getParameterNames(request);
	Element newElement =
document.createElement("request:all-parameter-values");

	for (int i = 0; i < parameterNames.length; i++) {
		Element paramElement = XSPRequestLibrary.getParameterValues(request,
parameterNames[i], document);
		newElement.appendChild(paramElement);
	}

	return(newElement);
}


It also includes additional functions which might make life easier and the
XML produced by the request taglib a little more terse for some
applications.

I'm sorry, I couldn't actually test a taglib snippet in request.xsl because
I haven't built my own taglibs yet. But it should look like somethign like
the following (only 'node' return types allowed):

  <xsl:template match="request:get-all-parameter-values">
    <xsl:variable name="as">
      <xsl:call-template name="value-for-as">
        <xsl:with-param name="default" select="'node'"/>
      </xsl:call-template>
    </xsl:variable>

    <xsp:expr>
      <xsl:choose>
        <xsl:when test="$as = 'node'">
          XSPRequestLibrary.getAllParameterValues(
            request,
            document
          )
        </xsl:when>
      </xsl:choose>
    </xsp:expr>
  </xsl:template>

Hope this helps someone. It helped me get request params into my XSL style
sheets.

Per.

Mime
View raw message