You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ugo Cei <u....@cbim.it> on 2003/01/08 21:51:27 UTC
[Flow] Possible fix for passing objects from flow to view
The current flow code has a problem when passing Java object from the
flow to the view using the sendPage and sendPageAndWait functions: all
the values in the map that is passed as the second argument to the
function get converted to strings. This makes it impossible to access
field values using JXPath, as described in the documentation.
I've come up with the following fix. It does not break any of the
examples and I've tested that Java objects are correctly passed.
However, it was more or less a wild guess and I'd like the fix to be
reviewed by Ovidiu or someone more knowledgeable than me about the
internals of Rhino and the flow.
Here's the diff,
Ugo
Index: JSCocoon.java
===================================================================
RCS file:
/home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSCocoon.java,v
retrieving revision 1.10
diff -u -r1.10 JSCocoon.java
--- JSCocoon.java 5 Dec 2002 09:37:20 -0000 1.10
+++ JSCocoon.java 8 Jan 2003 20:21:13 -0000
@@ -271,7 +271,8 @@
if (value == Undefined.instance)
value = null;
else
- value = ScriptRuntime.toPrimitive(value);
+ // value = ScriptRuntime.toPrimitive(value);
+ value = jsobjectToObject(value);
hash.put(key, value);
}
return hash;
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: [Flow] Possible fix for passing objects from flow to view
Posted by Ovidiu Predescu <ov...@apache.org>.
Hi Ugo,
Thanks for the fix, this seems to be correct. I'll apply your patch,
together with some other changes.
Regards,
Ovidiu
On Wednesday, Jan 8, 2003, at 12:51 US/Pacific, Ugo Cei wrote:
> The current flow code has a problem when passing Java object from the
> flow to the view using the sendPage and sendPageAndWait functions: all
> the values in the map that is passed as the second argument to the
> function get converted to strings. This makes it impossible to access
> field values using JXPath, as described in the documentation.
>
> I've come up with the following fix. It does not break any of the
> examples and I've tested that Java objects are correctly passed.
> However, it was more or less a wild guess and I'd like the fix to be
> reviewed by Ovidiu or someone more knowledgeable than me about the
> internals of Rhino and the flow.
>
> Here's the diff,
>
> Ugo
>
>
> Index: JSCocoon.java
> ===================================================================
> RCS file:
> /home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/components/
> flow/javascript/JSCocoon.java,v
> retrieving revision 1.10
> diff -u -r1.10 JSCocoon.java
> --- JSCocoon.java 5 Dec 2002 09:37:20 -0000 1.10
> +++ JSCocoon.java 8 Jan 2003 20:21:13 -0000
> @@ -271,7 +271,8 @@
> if (value == Undefined.instance)
> value = null;
> else
> - value = ScriptRuntime.toPrimitive(value);
> + // value = ScriptRuntime.toPrimitive(value);
> + value = jsobjectToObject(value);
> hash.put(key, value);
> }
> return hash;
>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org