You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Olivier Rossel <ol...@anyware-tech.com> on 2002/02/18 18:06:44 UTC

Having a function in a XSP.

Supposing I repaet 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?
Can I create an inner class with methods inside a XSP?


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

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


Re: Having a function in a XSP.

Posted by Nicola Ken Barozzi <ba...@nicolaken.com>.
From: "Olivier Rossel" <ol...@anyware-tech.com>

> 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                 krysalis.org@nicolaken.com
            - 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. <http://xml.apache.org/cocoon/faqs.html>

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