cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicola Ken Barozzi" <>
Subject Re: Having a function in a XSP.
Date Tue, 19 Feb 2002 08:11:06 GMT
From: "Olivier Rossel" <>

> Supposing I repeat the same XSP fragment several times in my XSP page.
> And I wish to "factorize" that with a function which receives
> parameters,  and
> is a kind of "XSP" fragment.
> Is it possible?

Taglibs have this role, to become libraries of commonly used xsp fragments.
But they are not functions, they behave similarly to macros AFAIK.

Taglibs are basically stylesheets that are applied to your XSP before it
gets compiled. This means that you cannot use taglibs as functions that
recieve live data; you can call taglibs only with predefined parameters. A
common way is to use attributes.

What can be done, is passing code fragments, so that the taglib uses those
to get live data.
I think that call-template can help you in calling taglibs with parameters.

A simple way of doing taglibs is to transform your xsp with your taglib
using Xalan and checking that the resulting file is the xsp that you want;
it's the xsp that gets compiled.

> Can I create an inner class with methods inside a XSP?

Don't think so. All XSP code goes in the resulting Generator's generate()
method. What you should do IMHO is to use helper classes.

For more information on taglibs, I suggest you to look at the cocoon builtin
taglibs in the sourcecode.

Nicola Ken Barozzi       
            - verba volant, scripta manent -
   (discussions get forgotten, just code remains)

Please check that your question has not already been answered in the
FAQ before posting. <>

To unsubscribe, e-mail: <>
For additional commands, e-mail: <>

View raw message