You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jan Harms <ja...@vivai.de> on 2004/05/13 15:38:36 UTC

JXTemplateGenerator: strange behaviour with jx:set

Hi,

I just found out that jx:set does not quite behave like I expected. Please consider the following JXTemplate snippets:

<!-- 1 -->
<element attr="${request.getAttribute('foo')}"/>

<!-- 2 -->
<jx:set var="foo" value="${request.getAttribute('foo')}"/>            
<element attr="${foo}"/>

1 and 2 should be equivalent, shouldn't they? Everything is fine as long as the request attribute 'foo' is available. However, if this is not the case (i.e. request.getAttribute('foo') evaluates to null) then the first snippet is transformed into 

<element attr="" />

while the latter is transformed into

<element attr="[Lorg.w3c.dom.Node;@6e3dee" />

Am I doing something wrong? Or is this a bug? I couldn't find anything about it in the mail archives.

I could imagine that the JXTemplateGenerator uses an empty DOM-Node as some kind of NullObject-Pattern. This would work inside xml element nodes (i.e. <element>${foo}</element> works fine in the second example), but would fail inside attributes. 

Any ideas?

Regards,

Jan Harms

P.S. I use cocoon 2.1.4.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org