You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ulrich Mayring <ul...@denic.de> on 2000/06/14 12:49:35 UTC
Re: Problem using taglib in custom logicsheet
Markus Bernhardt wrote:
>
> Now I want replace the static content with my own dynamic
> tags. I want evaluate a request-parameter, do some java
> stuff, and then output the result. Now I dont know, how
> and where to do it.
Hi Markus,
here is some working code for evaluating parameters:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<?cocoon-process type="xsp"?>
<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">
<page>
<xsp:logic>
Enumeration e = request.getParameterNames();
... do something with all params ...
String myparam = request.getParameter("myparam");
... do something with a specific param ...
</xsp:logic>
</page>
</xsp:page>
Or, in a stylesheet:
<xsl:variable
name="myparam"><xsp:expr>request.getParameter("myparam")</xsp:expr></xsl:variable>
Ulrich
--
Ulrich Mayring
DENIC eG, Systementwicklung
Re: Problem using taglib in custom logicsheet
Posted by Ricardo Rocha <ri...@apache.org>.
Markus Bernhardt wrote:
> But, why cant I do something like this:
> .....
> <xsl:template match="xsp:page">
> <xsp:page>
> .....
> <xsp:logic>
> private static String getMonth() {
> return request.getParameter("month");
> }
> </xsp:logic>
> .....
> </xsp:page>
> </xsl:template>
>
> <xsl:template match="calendar:month">
> <xsp:expr>getMonth()</xsp:expr>
> </xsl:template>
>
> The following error occurs:
> java.lang.Exception: XSP Java Compiler:
> Compilation failed for _calendar_dynamic.java 39:
> Undefined variable or class name: request
> String month = request.getParameter("month");
The request object is visible only inside the populateDocument() method.
If you want to use it from another method, you must explicitly pass it
as a parameter:
<xsl:template match="calendar:month">
<xsp:expr>getMonth(request)</xsp:expr>
</xsl:template>
Re: Problem using taglib in custom logicsheet
Posted by Markus Bernhardt <mb...@swsgmbh.de>.
Hi
ok, the following works now:
<xsl:template match="calendar:month">
<xsl:variable name="param">
<xsp:expr>request.getParameter("month")</xsp:expr>
</xsl:variable>
<xsp:expr>
<xsl:copy-of select="$param"/>
</xsp:expr>
</xsl:template>
But, why cant I do something like this:
.....
<xsl:template match="xsp:page">
<xsp:page>
.....
<xsp:logic>
private static String getMonth() {
return request.getParameter("month");
}
</xsp:logic>
.....
</xsp:page>
</xsl:template>
<xsl:template match="calendar:month">
<xsp:expr>getMonth()</xsp:expr>
</xsl:template>
The following error occurs:
java.lang.Exception: XSP Java Compiler:
Compilation failed for _calendar_dynamic.java 39:
Undefined variable or class name: request
String month = request.getParameter("month");
^
at
org.apache.cocoon.processor.xsp.language.java.XSPJavaProcessor.compile(XSPJavaProcessor.java:159)
at org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java:451)
at org.apache.cocoon.Engine.handle(Engine.java:305)
at org.apache.cocoon.Cocoon.service(Cocoon.java:167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:311)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)
at org.apache.jserv.JServConnection.run(JServConnection.java:188)
at java.lang.Thread.run(Thread.java)
Markus
Ulrich Mayring wrote:
> Markus Bernhardt wrote:
> >
> > Now I want replace the static content with my own dynamic
> > tags. I want evaluate a request-parameter, do some java
> > stuff, and then output the result. Now I dont know, how
> > and where to do it.
>
> Hi Markus,
>
> here is some working code for evaluating parameters:
>
> <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
> <?cocoon-process type="xsp"?>
>
> <xsp:page language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>
> <page>
>
> <xsp:logic>
> Enumeration e = request.getParameterNames();
> ... do something with all params ...
> String myparam = request.getParameter("myparam");
> ... do something with a specific param ...
> </xsp:logic>
>
> </page>
>
> </xsp:page>
>
> Or, in a stylesheet:
>
> <xsl:variable
> name="myparam"><xsp:expr>request.getParameter("myparam")</xsp:expr></xsl:variable>
>
> Ulrich
>
> --
> Ulrich Mayring
> DENIC eG, Systementwicklung
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org