cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ferenc Kiraly <ferenc.kir...@mobitel.si>
Subject passing request parameters to templates
Date Mon, 10 Mar 2003 12:13:52 GMT
	Hi!

I am trying to use <xsp-request:get-parameter name="..."/> as a
parameter to a template defined in my own logicsheet.

I have looked at the mailing list archives, the documentation and
actually found info on how it is supposed ot be done, but it seems
that the above parameter does not get passed on. I must be missing
something. Please help, cause I'm getting desperate.

In the code bellow, the custom <mobi:fmd-request> tag correctly writes
out the second DEBUG: line, but in the first DEBUG: line, the
variable $dowhat seems to be empty. If instead of supplying
a dynamic parameter to mobi:fmd-request, I supply an attribute
'dowhat', the code works as expected. If I supply a literal
string instead of <xsp-request:get-parameter name="dothething"/>,
the string does get passed on to the template as expected.

I am using Cocoon 2.0.4, with tomcat 4.1.18 and Java 1.4 from Sun.

	feri.

------------------------------------------------------

I tried the following in my XSP:

<mobi:fmd-request>
    <mobi:param name="dowhat"><xsp-request:get-parameter
                name="dothething"/></mobi:param>
</mobi:fmd-request>

And in the logischeet:

<xsl:template match="mobi:fmd-request">
   <xsl:variable name="dowhat">
     <xsl:call-template name="get-parameter">
      <xsl:with-param name="name">dowhat</xsl:with-param>
     </xsl:call-template>
   </xsl:variable>

   <xsl:text>DEBUG: dowhat: </xsl:text><xsl:value-of select="$dowhat"/><br/>
   <xsl:text>DEBUG: dowhat: </xsl:text><xsp-request:get-parameter 
name="dothething"/><br/>

   ...........................

</xsl:template>


<xsl:template name="get-parameter">
<xsl:param name="name"/>
<xsl:param name="default"/>
<xsl:param name="required">false</xsl:param>

<xsl:variable name="qname">
   <xsl:value-of select="concat('mobi', ':param')"/>
</xsl:variable>

<xsl:choose>
   <xsl:when test="@*[name(.) = $name]">
     <xsl:value-of select="@*[name(.) = $name]"/>
   </xsl:when>
   <xsl:when test="(*[name(.) = $qname])[@name = $name]">
     <xsl:call-template name="get-nested-content">
       <xsl:with-param name="content"
         select="(*[name(.) = $qname])[@name = $name]"/>
     </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>... handle default and error ...</xsl:otherwise>
</xsl:choose>
</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>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Mime
View raw message