You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Richard Bounds <ri...@richardbounds.co.uk> on 2003/01/03 15:46:53 UTC

Passing parameters to a logicsheet tag using xsp:param

Dear all,

I'm trying to write a logicsheet that accepts dynamic parameters from the
XSP page (e.g. maybe request parameters, or session attributes), and uses
them to request data from our application. I'd like the xsp code to look
something like this:



	<xsp:logic>
   		String sortParameter = request.getParameter("sort");
	</xsp:logic>

	<data>
	   <parameters:categories>
	   		<xsp:param name="sortBy">
				<xsp:expr>sortParameter</xsp:expr>								</xsp:param>
	   </parameters:categories>
   	</data>



What do I need to put in my logicsheet code to pick up the "sortParameter"
value? At the moment I've got the following:



<xsl:template match="parameters:categories">

  <xsl:variable name="sortBy">
  <xsl:choose>
      <xsl:when test="sortBy">
        <xsl:call-template name="get-nested-content">
          <xsl:with-param name="content" select="parameters:sortBy"/>
        </xsl:call-template>
      </xsl:when>
    </xsl:choose>
  </xsl:variable>

	<xsp:logic>
		   System.out.println("Got value: " + "<xsl:copy-of select="$sortBy" />");
	</xsp:logic>

</xsl:template>

 <xsl:template name="get-nested-content">
    <xsl:param name="content"/>
    <xsl:choose>
      <xsl:when test="$content/*">
        <xsl:apply-templates select="$content/*"/>
      </xsl:when>
      <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
    </xsl:choose>
  </xsl:template>



Sorry if this is a stupid question, but I've been unable to find any
documentation that  describes this. I'd be very grateful for any help!

Richard


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Passing parameters to a logicsheet tag using xsp:param

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 03.Jan.2003 -- 02:46 PM, Richard Bounds wrote:
> Dear all,
> 
> I'm trying to write a logicsheet that accepts dynamic parameters from the
> XSP page (e.g. maybe request parameters, or session attributes), and uses
> them to request data from our application. I'd like the xsp code to look
> something like this:
> 
> 
> 
> 	<xsp:logic>
>    		String sortParameter = request.getParameter("sort");
> 	</xsp:logic>
> 
> 	<data>
> 	   <parameters:categories>
> 	   		<xsp:param name="sortBy">
> 				<xsp:expr>sortParameter</xsp:expr>								</xsp:param>
> 	   </parameters:categories>
>    	</data>
> 
> 
> 
> What do I need to put in my logicsheet code to pick up the "sortParameter"
> value? At the moment I've got the following:
> 
> 
> 
> <xsl:template match="parameters:categories">
> 
>   <xsl:variable name="sortBy">
>   <xsl:choose>
>       <xsl:when test="sortBy">
>         <xsl:call-template name="get-nested-content">
>           <xsl:with-param name="content" select="parameters:sortBy"/>
>         </xsl:call-template>
>       </xsl:when>
>     </xsl:choose>
>   </xsl:variable>
> 
> 	<xsp:logic>
> 		   System.out.println("Got value: " + "<xsl:copy-of select="$sortBy" />");
> 	</xsp:logic>
> 
> </xsl:template>
> 
>  <xsl:template name="get-nested-content">
>     <xsl:param name="content"/>
>     <xsl:choose>
>       <xsl:when test="$content/*">
>         <xsl:apply-templates select="$content/*"/>
>       </xsl:when>
>       <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
>     </xsl:choose>
>   </xsl:template>

Look at the logicsheet-utils.xsl included in cocoon. It provides the
most commonly used templates including a get-nested-content named
template. Look at util.xsl as well as that logicsheet uses
logicsheet-utils.xsl for an idea how to do it.

	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>