You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jeremy Quinn <je...@media.demon.co.uk> on 2003/08/20 16:35:14 UTC

can you reach sitemap params from JXTemplate?

Hi All

Does anyone know the correct syntax for getting a Sitemap parameter in 
JXTemplate?

I have tried all of the following:

#{cocoon/parameters["publishedJobServer"]}
#{cocoon/parameters/publishedJobServer/}
${cocoon.parameters["publishedJobServer"]}
${cocoon.getParameters("publishedJobServer")}
${cocoon.parameters.publishedJobServer}


The first two throw exceptions, the others output nothing.
I can use cocoon.getParameters("publishedJobServer") in my FlowScript 
without a problem, but I would prefer not to have to pass it specially 
to the view in cocoon.sendPage().

Any ideas?

thanks

regards Jeremy


Re: can you reach sitemap params from JXTemplate?

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Thursday, August 21, 2003, at 07:27 AM, Giacomo Pati wrote:

> On Wed, 20 Aug 2003, Jeremy Quinn wrote:
>
>> I cannot get this to work, I get:
>> org.apache.commons.jxpath.JXPathException: Invalid XPath:
>> '$parameters.getParameter(\"publishedJobServer\")'. Syntax error 
>> after:
>> '$p'
>>
>> If I try :
>>
>> ${$parameters.getParameter('publishedJobServer')}
>
> Use: ${request.getParameter('publishedJobServery')}
>
> this works for me.

I still get no output.

Thanks

regards Jeremy


Re: can you reach sitemap params from JXTemplate?

Posted by Giacomo Pati <gi...@apache.org>.
On Wed, 20 Aug 2003, Jeremy Quinn wrote:

> I cannot get this to work, I get:
> org.apache.commons.jxpath.JXPathException: Invalid XPath:
> '$parameters.getParameter(\"publishedJobServer\")'. Syntax error after:
> '$p'
>
> If I try :
>
> ${$parameters.getParameter('publishedJobServer')}

Use: ${request.getParameter('publishedJobServery')}

this works for me.

--
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com


Re: can you reach sitemap params from JXTemplate?

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Wednesday, August 20, 2003, at 06:11 PM, Sylvain Wallez wrote:

> Jeremy Quinn wrote:
>
>> Hi All
>>
>> Does anyone know the correct syntax for getting a Sitemap parameter 
>> in JXTemplate?
>>
>> I have tried all of the following:
>>
>> #{cocoon/parameters["publishedJobServer"]}
>> #{cocoon/parameters/publishedJobServer/}
>> ${cocoon.parameters["publishedJobServer"]}
>> ${cocoon.getParameters("publishedJobServer")}
>> ${cocoon.parameters.publishedJobServer}
>>
>>
>> The first two throw exceptions, the others output nothing.
>> I can use cocoon.getParameters("publishedJobServer") in my FlowScript 
>> without a problem, but I would prefer not to have to pass it 
>> specially to the view in cocoon.sendPage().
>>
>> Any ideas?
>
>
> The "cocoon" object only exists in the flowscript. In JXTemplate, you 
> can directly access the "parameters" variable : 
> #{$parameters.getParameter('publishedJobServer')}
>

I cannot get this to work, I get:
org.apache.commons.jxpath.JXPathException: Invalid XPath: 
'$parameters.getParameter(\"publishedJobServer\")'. Syntax error after: 
'$p'

If I try :

${$parameters.getParameter('publishedJobServer')}

nothing happens

> This makes me think we should unify the notation across the various 
> components of a flow-script application.
> In this regard, it would be more consistent to have "request", 
> "session", "context" and "parameter" as children of a "cocoon" 
> variable instead of having them directly as toplevel variables.

I agree

> Or are they available as toplevel variables to mimic JSTL from which 
> JXTemplate is inspired ?

They look like they are by a cursory reading of the code, but I have 
not been able to read many yet ;)

Thanks for your suggestions

regards Jeremy


Re: can you reach sitemap params from JXTemplate?

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Jeremy Quinn wrote:

> Hi All
>
> Does anyone know the correct syntax for getting a Sitemap parameter in 
> JXTemplate?
>
> I have tried all of the following:
>
> #{cocoon/parameters["publishedJobServer"]}
> #{cocoon/parameters/publishedJobServer/}
> ${cocoon.parameters["publishedJobServer"]}
> ${cocoon.getParameters("publishedJobServer")}
> ${cocoon.parameters.publishedJobServer}
>
>
> The first two throw exceptions, the others output nothing.
> I can use cocoon.getParameters("publishedJobServer") in my FlowScript 
> without a problem, but I would prefer not to have to pass it specially 
> to the view in cocoon.sendPage().
>
> Any ideas? 


The "cocoon" object only exists in the flowscript. In JXTemplate, you 
can directly access the "parameters" variable : 
#{$parameters.getParameter('publishedJobServer')}

This makes me think we should unify the notation across the various 
components of a flow-script application. In this regard, it would be 
more consistent to have "request", "session", "context" and "parameter" 
as children of a "cocoon" variable instead of having them directly as 
toplevel variables.

Or are they available as toplevel variables to mimic JSTL from which 
JXTemplate is inspired ?

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com



Re: can you reach sitemap params from JXTemplate?

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Friday, August 22, 2003, at 10:10 AM, Giacomo Pati wrote:

> Ok, the sitemap parameters specified on the flow pipeline are not
> accessible from the view pipeline (you should have got an Exception 
> "The
> parameter 'status' does not contain a value"). The view pipeline gets
> its on set of parameters IIRC.
>

AH!!

<smacks-forehead/>

Many thanks!!!

Sorry for the wasted bandwidth!!!

regards Jeremy


Re: can you reach sitemap params from JXTemplate?

Posted by Giacomo Pati <gi...@apache.org>.
On Fri, 22 Aug 2003, Jeremy Quinn wrote:

> My sitemap looks like this:
>
> <map:component-configurations>
> 	<global-variables>
> 		<assetResository>/Library/Apache2/assets/</assetResository>
> 		<assetServer>http://iborg.local/assets/</assetServer>
> 		<pending>pending/</pending>
> 		<published>archive/</published>
> 		<removed>trash/</removed>
> 	</global-variables>
> </map:component-configurations>
>
> <snip/>
>
> <map:match pattern="*/*">
> 	<map:call function="main">
> 		<map:parameter name="action" value="{1}"/>
> 		<map:parameter name="id" value="{2}"/>
> 		<map:parameter name="uri" value="{0}"/>
> 		<map:parameter name="pendingJobRepository"
> 			 value="{global:assetResository}{global:pending}"/>
> 		<map:parameter name="pendingJobServer"
> 			 value="{global:assetServer}{global:pending}"/>
> 		<map:parameter name="publishedJobRepository"
> 			 value="{global:assetResository}{global:published}"/>
> 		<map:parameter name="publishedJobServer"
> 			 value="{global:assetServer}{global:published}"/>
> 		<map:parameter name="removedJobRepository"
> 			 value="{global:assetResository}{global:removed}"/>
> 	</map:call>
> </map:match>

Ok, the sitemap parameters specified on the flow pipeline are not
accessible from the view pipeline (you should have got an Exception "The
parameter 'status' does not contain a value"). The view pipeline gets
its on set of parameters IIRC.

--
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com


Re: can you reach sitemap params from JXTemplate?

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Thursday, August 21, 2003, at 07:09 PM, Christopher Oliver wrote:

> Sorry, my bad, the JXPath version should be this:
>
> #{getParameter($parameters, 'publishedJobServer')}

this one results in :
org.apache.cocoon.ProcessingException: Failed to execute pipeline.:  
file:/Library/Tomcat/webapps/cocoon/editor/screens/util/ 
chooseResourceJob.xml:74:86:org.apache.commons.jxpath.JXPathException:  
Cannot invoke public java.lang.String  
org.apache.avalon.framework.parameters.Parameters.getParameter(java.lang 
.String) throws  
org.apache.avalon.framework.parameters.ParameterException; The  
parameter 'publishedJobServer' does not contain a value

> and the Jexl version:
>
> ${parameters.getParameter('publishedJobServer')}

this one outputs nothing

>
> These do work (at least for me). The fact that you got no output from  
> the Jexl version would seem to indicate that the specified parameter  
> wasn't present. You can also call any method of  
> org.apache.avalon.framework.parameters.Parameters, for example, try  
> this:
>
> <t:forEach var="paramName" items="${parameters.getNames()}">
>   name=${paramName}, value=${parameters.getParameter(paramName)}
> </t:forEach>

this outputs nothing

My sitemap looks like this:

<map:component-configurations>
	<global-variables>
		<assetResository>/Library/Apache2/assets/</assetResository>
		<assetServer>http://iborg.local/assets/</assetServer>
		<pending>pending/</pending>
		<published>archive/</published>
		<removed>trash/</removed>
	</global-variables>
</map:component-configurations>

<snip/>

<map:match pattern="*/*">
	<map:call function="main">
		<map:parameter name="action" value="{1}"/>
		<map:parameter name="id" value="{2}"/>
		<map:parameter name="uri" value="{0}"/>
		<map:parameter name="pendingJobRepository"
			 value="{global:assetResository}{global:pending}"/>
		<map:parameter name="pendingJobServer"
			 value="{global:assetServer}{global:pending}"/>
		<map:parameter name="publishedJobRepository"
			 value="{global:assetResository}{global:published}"/>
		<map:parameter name="publishedJobServer"
			 value="{global:assetServer}{global:published}"/>
		<map:parameter name="removedJobRepository"
			 value="{global:assetResository}{global:removed}"/>
	</map:call>
</map:match>

This line of flowscript works fine :

job.moveTo (cocoon.parameters["publishedJobRepository"]);

> HTH,

Thanks for trying :)

regards Jeremy

>
> Chris
>
> Christopher Oliver wrote:
>
>> Yes, it's a bug.
>>
>> Jeremy Quinn wrote:
>>
>>>
>>> On Thursday, August 21, 2003, at 02:10 AM, Christopher Oliver wrote:
>>>
>>>> This is how you do it:
>>>>
>>>> #{$parameters.getParameter("publishedJobServer")}
>>>
>>>
>>>
>>> results in :
>>> org.apache.commons.jxpath.JXPathException: Invalid XPath:  
>>> '$parameters.getParameter(\"publishedJobServer\")'. Syntax error  
>>> after: '$p'
>>>
>>>
>>>>
>>>> ${parameters.getParameter("publishedJobServer")}
>>>>
>>>
>>> no output
>>>
>>> so I guess it must be a bug?
>>>
>>> Thanks for your suggestions
>>>
>>> regards Jeremy
>>>
>>>
>>
>>
>>
>
>


Re: can you reach sitemap params from JXTemplate?

Posted by Christopher Oliver <re...@verizon.net>.
Sorry, my bad, the JXPath version should be this:

#{getParameter($parameters, 'publishedJobServer')}

and the Jexl version:

${parameters.getParameter('publishedJobServer')}

These do work (at least for me). The fact that you got no output from 
the Jexl version would seem to indicate that the specified parameter 
wasn't present. You can also call any method of 
org.apache.avalon.framework.parameters.Parameters, for example, try this:

<t:forEach var="paramName" items="${parameters.getNames()}">
   name=${paramName}, value=${parameters.getParameter(paramName)}
</t:forEach>

HTH,

Chris

Christopher Oliver wrote:

> Yes, it's a bug.
>
> Jeremy Quinn wrote:
>
>>
>> On Thursday, August 21, 2003, at 02:10 AM, Christopher Oliver wrote:
>>
>>> This is how you do it:
>>>
>>> #{$parameters.getParameter("publishedJobServer")}
>>
>>
>>
>> results in :
>> org.apache.commons.jxpath.JXPathException: Invalid XPath: 
>> '$parameters.getParameter(\"publishedJobServer\")'. Syntax error 
>> after: '$p'
>>
>>
>>>
>>> ${parameters.getParameter("publishedJobServer")}
>>>
>>
>> no output
>>
>> so I guess it must be a bug?
>>
>> Thanks for your suggestions
>>
>> regards Jeremy
>>
>>
>
>
>



Re: can you reach sitemap params from JXTemplate?

Posted by Christopher Oliver <re...@verizon.net>.
Yes, it's a bug.

Jeremy Quinn wrote:

>
> On Thursday, August 21, 2003, at 02:10 AM, Christopher Oliver wrote:
>
>> This is how you do it:
>>
>> #{$parameters.getParameter("publishedJobServer")}
>
>
> results in :
> org.apache.commons.jxpath.JXPathException: Invalid XPath: 
> '$parameters.getParameter(\"publishedJobServer\")'. Syntax error 
> after: '$p'
>
>
>>
>> ${parameters.getParameter("publishedJobServer")}
>>
>
> no output
>
> so I guess it must be a bug?
>
> Thanks for your suggestions
>
> regards Jeremy
>
>



Re: can you reach sitemap params from JXTemplate?

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Thursday, August 21, 2003, at 02:10 AM, Christopher Oliver wrote:

> This is how you do it:
>
> #{$parameters.getParameter("publishedJobServer")}

results in :
org.apache.commons.jxpath.JXPathException: Invalid XPath: 
'$parameters.getParameter(\"publishedJobServer\")'. Syntax error after: 
'$p'


>
> ${parameters.getParameter("publishedJobServer")}
>

no output

so I guess it must be a bug?

Thanks for your suggestions

regards Jeremy


Re: can you reach sitemap params from JXTemplate?

Posted by Christopher Oliver <re...@verizon.net>.
This is how you do it:

#{$parameters.getParameter("publishedJobServer")}

${parameters.getParameter("publishedJobServer")}



Jeremy Quinn wrote:

>
> On Wednesday, August 20, 2003, at 05:42 PM, Reinhard Pötz wrote:
>
>> Without trying it ...
>> #{parameters.myParameter} should do it ...
>
>
> no go
>
> tried both:
>
> #{parameters.publishedJobServer}
> ${parameters.publishedJobServer}
>
> no output on either
>
> thanks
>
> regards Jeremy
>
>>
>> Cheers,
>> Reinhard
>>
>>> -----Original Message-----
>>> From: Jeremy Quinn [mailto:jeremy@media.demon.co.uk]
>>> Sent: Wednesday, August 20, 2003 4:35 PM
>>> To: dev@cocoon.apache.org
>>> Subject: can you reach sitemap params from JXTemplate?
>>>
>>>
>>> Hi All
>>>
>>> Does anyone know the correct syntax for getting a Sitemap
>>> parameter in
>>> JXTemplate?
>>>
>>> I have tried all of the following:
>>>
>>> #{cocoon/parameters["publishedJobServer"]}
>>> #{cocoon/parameters/publishedJobServer/}
>>> ${cocoon.parameters["publishedJobServer"]}
>>> ${cocoon.getParameters("publishedJobServer")}
>>> ${cocoon.parameters.publishedJobServer}
>>>
>>>
>>> The first two throw exceptions, the others output nothing.
>>> I can use cocoon.getParameters("publishedJobServer") in my FlowScript
>>> without a problem, but I would prefer not to have to pass it
>>> specially
>>> to the view in cocoon.sendPage().
>>>
>>> Any ideas?
>>>
>>> thanks
>>>
>>> regards Jeremy
>>>
>>
>
>



Re: can you reach sitemap params from JXTemplate?

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Thursday, August 21, 2003, at 07:46 AM, Giacomo Pati wrote:

> On Wed, 20 Aug 2003, Jeremy Quinn wrote:
>
>>
>> On Wednesday, August 20, 2003, at 05:42 PM, Reinhard Pötz wrote:
>>
>>> Without trying it ...
>>> #{parameters.myParameter} should do it ...
>>
>> no go
>>
>> tried both:
>>
>> #{parameters.publishedJobServer}
>> ${parameters.publishedJobServer}
>
> I don't think there is any other possibility as
> '${request.getParameter("foo")}' or '${parameters.getParameter("foo")}'
> because the '#' prefix needs to operate on java beans which isn't the
> case neither for the request's getParameter method nor for the
> parameters' getParameter method.
>
> BTW: if you use the '#' prefix the expression is evaluated using the
> commons-jxpath tool which expects a xpath syntax, the '$' prefix uses
> the commons-jexl project for expression evaluation which is more like
> JSTL expressions.

I think I should write some (flow + xml) test cases for trying out the 
different ways of getting the various parameters and other Objects 
(like Maps, Sets, Beans etc) extracted by JXTemplate.

I am off to N.Ireland for a weeks diving on Friday, I will be taking my 
'poota, so hopefully will come back with these written.

But regardless of that, I think the idea Sylvain had of unifying the 
object-space available to JXTemplate with the FOM, has some merit.

regards Jeremy


Re: can you reach sitemap params from JXTemplate?

Posted by Giacomo Pati <gi...@apache.org>.
On Wed, 20 Aug 2003, Jeremy Quinn wrote:

>
> On Wednesday, August 20, 2003, at 05:42 PM, Reinhard Pötz wrote:
>
> > Without trying it ...
> > #{parameters.myParameter} should do it ...
>
> no go
>
> tried both:
>
> #{parameters.publishedJobServer}
> ${parameters.publishedJobServer}

I don't think there is any other possibility as
'${request.getParameter("foo")}' or '${parameters.getParameter("foo")}'
because the '#' prefix needs to operate on java beans which isn't the
case neither for the request's getParameter method nor for the
parameters' getParameter method.

BTW: if you use the '#' prefix the expression is evaluated using the
commons-jxpath tool which expects a xpath syntax, the '$' prefix uses
the commons-jexl project for expression evaluation which is more like
JSTL expressions.

--
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com


Re: can you reach sitemap params from JXTemplate?

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Wednesday, August 20, 2003, at 05:42 PM, Reinhard Pötz wrote:

> Without trying it ...
> #{parameters.myParameter} should do it ...

no go

tried both:

#{parameters.publishedJobServer}
${parameters.publishedJobServer}

no output on either

thanks

regards Jeremy

>
> Cheers,
> Reinhard
>
>> -----Original Message-----
>> From: Jeremy Quinn [mailto:jeremy@media.demon.co.uk]
>> Sent: Wednesday, August 20, 2003 4:35 PM
>> To: dev@cocoon.apache.org
>> Subject: can you reach sitemap params from JXTemplate?
>>
>>
>> Hi All
>>
>> Does anyone know the correct syntax for getting a Sitemap
>> parameter in
>> JXTemplate?
>>
>> I have tried all of the following:
>>
>> #{cocoon/parameters["publishedJobServer"]}
>> #{cocoon/parameters/publishedJobServer/}
>> ${cocoon.parameters["publishedJobServer"]}
>> ${cocoon.getParameters("publishedJobServer")}
>> ${cocoon.parameters.publishedJobServer}
>>
>>
>> The first two throw exceptions, the others output nothing.
>> I can use cocoon.getParameters("publishedJobServer") in my FlowScript
>> without a problem, but I would prefer not to have to pass it
>> specially
>> to the view in cocoon.sendPage().
>>
>> Any ideas?
>>
>> thanks
>>
>> regards Jeremy
>>
>


RE: can you reach sitemap params from JXTemplate?

Posted by Reinhard Pötz <re...@apache.org>.
Without trying it ...
#{parameters.myParameter} should do it ...

Cheers,
Reinhard

> -----Original Message-----
> From: Jeremy Quinn [mailto:jeremy@media.demon.co.uk] 
> Sent: Wednesday, August 20, 2003 4:35 PM
> To: dev@cocoon.apache.org
> Subject: can you reach sitemap params from JXTemplate?
> 
> 
> Hi All
> 
> Does anyone know the correct syntax for getting a Sitemap 
> parameter in 
> JXTemplate?
> 
> I have tried all of the following:
> 
> #{cocoon/parameters["publishedJobServer"]}
> #{cocoon/parameters/publishedJobServer/}
> ${cocoon.parameters["publishedJobServer"]}
> ${cocoon.getParameters("publishedJobServer")}
> ${cocoon.parameters.publishedJobServer}
> 
> 
> The first two throw exceptions, the others output nothing.
> I can use cocoon.getParameters("publishedJobServer") in my FlowScript 
> without a problem, but I would prefer not to have to pass it 
> specially 
> to the view in cocoon.sendPage().
> 
> Any ideas?
> 
> thanks
> 
> regards Jeremy
>