cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Cocoon Wiki] Update of "PerlScriptGenerator" by FosterHersey
Date Tue, 14 Feb 2006 23:09:31 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change notification.

The following page has been changed by FosterHersey:
http://wiki.apache.org/cocoon/PerlScriptGenerator

New page:
===  Download ===
Download the bsfperl.jar from [http://bsfperl.sourceforge.net] and put it into the WEB-INF/lib
directory of your webapp. If you want to rebuild your Cocoon you should copy it also to the
lib/local directory of your Cocoon sources, otherwise the JAR will be lost after the build.

===  Sitemap entry ===
{{{
<map:match pattern="hello.pl">
  <map:generate src="hello.pl" type="script">
    <map:parameter name="userName" value="Perl Lover"/>
  </map:generate>
  <map:serialize type="xml"/>
</map:match>
}}}

===  Perl script (hello.pl) ===
{{{

use strict;

# 
# a bean scripting framework object, 
# $bsf, is provided to us by bsfperl.
# 

#get the output String buffer
my $bsf_output = $bsf->lookupBean("output");

#get the Parameters object
my $bsf_parameters = $bsf->lookupBean("parameters");

#get the value of the parameter "key" defined in the sitemap
my $username = $bsf_parameters->getParameter("userName");

#generate xml
$bsf_output->append("<xml>" . "Hello, " . $username . "!" . "</xml>");
}}}

(tested with 2.1.8)

===  See Also ===
 *PythonScriptGenerator
 *[http://cocoon.apache.org/2.1/userdocs/script-generator.html ScriptGenerator in Cocoon 2.1]

Mime
View raw message