cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ovidiu Predescu <ovi...@cup.hp.com>
Subject Re: how to pass request param into taglib parameter?
Date Fri, 05 Jan 2001 19:13:16 GMT
On Fri, 5 Jan 2001 10:25:52 -0800 (PST), Stephen Chang <schav_2000@yahoo.com> 
wrote:

> hello all,
> 
> thanks for all the help so far from everyone. it's
> been very helpful!
> 
> anyways, i am making use of my own tag library in an
> XSP page. This taglib call requires input parameters
> in the form of XML elements like:
> 
> <mylib:mytag>
> <param1><xsp:expr>value1</xsp:expr></param1>
> <param2><xsp:expr>value2</xsp:expr></param2>
> </mylib:mytag>
> 
> The way i am using it, my "value1" and "value2" are
> varibles read in the beginning in an <xsp:logic/>
> block like:
> <xsp:logic>
> String value1 = request.getParameter("v1");
> String value2 = request.getParameter("v2");
> </xsp:logic>
> 
> My taglib logicsheet never receives the values of
> value1 and value2. Instead they have blank values so
> nothing is passed to my taglib logic. I looked at the
> generated file and saw that empty parameters were
> being passed into my taglib logic. What's going on?
> 
> Does this have anything to do with the order of XSP
> processing on the page, as I have an <xsp:expr> inside
> a user-defined taglib which also is expanded by the
> XSP processor?

The taglib is expanded by the XSLT processor. If you want to put the name of
the variables value1 and value2 in the code generated by your taglib, don't use
<xsp:expr>, use the name of the variable. Something like this:

<mylib:mytag>
  <param1>value1</param1>
  <param2>value2</param2>
</mylib:mytag>

The template for mylib:mytag will look like this then:

<xsl:template match="mylib:mytag">
  {
    String arg1 = <xsl:value-of select="param1">;
    String arg2 = <xsl:value-of select="param2">;
    ...
    // do something with arg1 and arg2
  }
</xsl:template>

Keep in mind that the stylesheet for your taglib should generate code, and that
you don't have to make any assumptions on what is generated in previous
transformation steps.

Regards,
-- 
Ovidiu Predescu <ovidiu@cup.hp.com>
http://orion.nsr.hp.com/ (inside HP's firewall only)
http://www.geocities.com/SiliconValley/Monitor/7464/



Mime
View raw message