You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jorg Heymans <jh...@domek.be> on 2005/04/18 16:22:28 UTC

attaching an object to sendpage

Hi,

I would like to do the following

cocoon.sendPage("streamdata", {"dataobject" , data} );

and then in the generator setup() of the streamdata pipeline somehow 
grab this "dataObject" object.


Regards
Jorg


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


Re: attaching an object to sendpage

Posted by Thomas Torsney-Weir <TT...@Bear.com>.
> Funny though that this isn't easily doable. I would've thought that 
> passing an object from flow to a non-JX pipeline is common stuff - guess 
> i was wrong :-)

I've done this by passing a java Map object from flow instead of the 
javascript version.  Then the context object you pull out will be the 
map.  I'm pretty sure this isn't a good way to do it and it doesn't work 
in all cases -- in particular with cforms  -- but it might help you.


***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation, 
offer or agreement or any information about any transaction, customer 
account or account activity contained in this communication.
***********************************************************************


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


Re: attaching an object to sendpage

Posted by Jorg Heymans <jh...@domek.be>.
Upayavira wrote:
> 
> 
> Have you ever used JXPath? That would be one way. Otherwise, does the 
> NativeObject have an 'unwrap' option? Then you could cast the unwrapped 
> object. I'm guessing now though.

JXPath didn't have the capabilities I needed for generating my SAX 
stream, that's why i went with a custom generator instead.

It looks like the nativeobject has most of the properties available to 
call the methods i want in a Javascript way. But I think i'll just stick 
to passing it via the Request, even though it's less declarative to see 
what's going on in my code.

Funny though that this isn't easily doable. I would've thought that 
passing an object from flow to a non-JX pipeline is common stuff - guess 
i was wrong :-)


Thanks for your help
Jorg


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


Re: attaching an object to sendpage

Posted by WeeZard <we...@email.si>.
this is for unwraping NativeJavaObjects,

Scriptable fsbean = (Scriptable) FlowHelper.getContextObject(objectModel);
Object currentBean = ScriptableObject.getProperty((Scriptable) fsbean, 
"beanName");
if (currentBean instanceof NativeJavaObject) currentBean  = 
((NativeJavaObject) currentBean).unwrap();


if anyone knows how to unwrap org.mozilla.javascript.NativeObject, please 
post here.

Weez


----- Original Message ----- 
From: "Upayavira" <uv...@odoko.co.uk>
To: <us...@cocoon.apache.org>
Sent: Monday, April 18, 2005 6:37 PM
Subject: Re: attaching an object to sendpage


> Jorg Heymans wrote:
>> How can i get at the original object using the flowhelper syntax you 
>> suggested :
>>
>> Object bean = FlowHelper.getContextObject(objectModel)
>>
>> bean is of class org.mozilla.javascript.NativeObject, it doesn't look 
>> like i can get my original object back from this.
>>
>> I think i'll have to just go via the request object.
>
> Have you ever used JXPath? That would be one way. Otherwise, does the 
> NativeObject have an 'unwrap' option? Then you could cast the unwrapped 
> object. I'm guessing now though.
>
> Regards, Upayavira
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


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


Re: attaching an object to sendpage

Posted by Upayavira <uv...@odoko.co.uk>.
Jorg Heymans wrote:
> How can i get at the original object using the flowhelper syntax you 
> suggested :
> 
> Object bean = FlowHelper.getContextObject(objectModel)
> 
> bean is of class org.mozilla.javascript.NativeObject, it doesn't look 
> like i can get my original object back from this.
> 
> I think i'll have to just go via the request object.

Have you ever used JXPath? That would be one way. Otherwise, does the 
NativeObject have an 'unwrap' option? Then you could cast the unwrapped 
object. I'm guessing now though.

Regards, Upayavira

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


Re: attaching an object to sendpage

Posted by Jorg Heymans <jh...@domek.be>.
How can i get at the original object using the flowhelper syntax you 
suggested :

Object bean = FlowHelper.getContextObject(objectModel)

bean is of class org.mozilla.javascript.NativeObject, it doesn't look 
like i can get my original object back from this.

I think i'll have to just go via the request object.

Thoughts?
Jorg

Upayavira wrote:
> flow-attribute would return a string, yes. Has been discussed to allow 
> it to return objects, but right now it would be a string.
> 
> Regards, Upayavira
> 
> 
> Jorg Heymans wrote:
> 
>> Actually
>>
>> <map:generate ...>
>>    <map parameter name="data" value="{flow-attribute:dataobject}">
>>
>> doesn't work in my case as i need the object as a whole. I don't think 
>> the map:parameter syntax allows pojos as values, or does it ?
>>
>> Thanks
>> Jorg
>>
>> Upayavira wrote:
>>
>>> Jorg Heymans wrote:
>>>
>>>> I see, and then in my generator declaration i would do
>>>> <map:generate ...>
>>>>    <map parameter name="data" value="{flow-attribute:dataobject}">
>>>> ?
>>>>
>>>> Is the flow-attribute held in request scope? This data might/will 
>>>> get overwritten with concurrent requests from the same client, which 
>>>> is very possible in my application.
>>>>
>>>> I guess the FlowHelper syntax equivalent is
>>>> Object bean = FlowHelper.getContextObject(objectModel) , but i have 
>>>> the same remark here : is the variable stored request-local ?
>>>
>>>
>>>
>>>
>>> Yes. Has to be, or everything would break!
>>>
>>> Regards, Upayavira
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>


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


Re: attaching an object to sendpage

Posted by Upayavira <uv...@upaya.co.uk>.
flow-attribute would return a string, yes. Has been discussed to allow 
it to return objects, but right now it would be a string.

Regards, Upayavira


Jorg Heymans wrote:
> Actually
> 
> <map:generate ...>
>    <map parameter name="data" value="{flow-attribute:dataobject}">
> 
> doesn't work in my case as i need the object as a whole. I don't think 
> the map:parameter syntax allows pojos as values, or does it ?
> 
> Thanks
> Jorg
> 
> Upayavira wrote:
> 
>> Jorg Heymans wrote:
>>
>>> I see, and then in my generator declaration i would do
>>> <map:generate ...>
>>>    <map parameter name="data" value="{flow-attribute:dataobject}">
>>> ?
>>>
>>> Is the flow-attribute held in request scope? This data might/will get 
>>> overwritten with concurrent requests from the same client, which is 
>>> very possible in my application.
>>>
>>> I guess the FlowHelper syntax equivalent is
>>> Object bean = FlowHelper.getContextObject(objectModel) , but i have 
>>> the same remark here : is the variable stored request-local ?
>>
>>
>>
>> Yes. Has to be, or everything would break!
>>
>> Regards, Upayavira
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


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


Re: attaching an object to sendpage

Posted by Jorg Heymans <jh...@domek.be>.
Actually

<map:generate ...>
    <map parameter name="data" value="{flow-attribute:dataobject}">

doesn't work in my case as i need the object as a whole. I don't think 
the map:parameter syntax allows pojos as values, or does it ?

Thanks
Jorg

Upayavira wrote:
> Jorg Heymans wrote:
> 
>> I see, and then in my generator declaration i would do
>> <map:generate ...>
>>    <map parameter name="data" value="{flow-attribute:dataobject}">
>> ?
>>
>> Is the flow-attribute held in request scope? This data might/will get 
>> overwritten with concurrent requests from the same client, which is 
>> very possible in my application.
>>
>> I guess the FlowHelper syntax equivalent is
>> Object bean = FlowHelper.getContextObject(objectModel) , but i have 
>> the same remark here : is the variable stored request-local ?
> 
> 
> Yes. Has to be, or everything would break!
> 
> Regards, Upayavira


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


Re: attaching an object to sendpage

Posted by Upayavira <uv...@upaya.co.uk>.
Jorg Heymans wrote:
> I see, and then in my generator declaration i would do
> <map:generate ...>
>    <map parameter name="data" value="{flow-attribute:dataobject}">
> ?
> 
> Is the flow-attribute held in request scope? This data might/will get 
> overwritten with concurrent requests from the same client, which is very 
> possible in my application.
> 
> I guess the FlowHelper syntax equivalent is
> Object bean = FlowHelper.getContextObject(objectModel) , but i have the 
> same remark here : is the variable stored request-local ?

Yes. Has to be, or everything would break!

Regards, Upayavira

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


Re: attaching an object to sendpage

Posted by Jorg Heymans <jh...@domek.be>.
I see, and then in my generator declaration i would do
<map:generate ...>
    <map parameter name="data" value="{flow-attribute:dataobject}">
?

Is the flow-attribute held in request scope? This data might/will get 
overwritten with concurrent requests from the same client, which is very 
possible in my application.

I guess the FlowHelper syntax equivalent is
Object bean = FlowHelper.getContextObject(objectModel) , but i have the 
same remark here : is the variable stored request-local ?

Thanks
Jorg

Upayavira wrote:
> Or use the FlowHelper class.
> 
> Regards, Upayavira
> 
> Arsen A. Gutsal wrote:
> 
>> {flow-attribute:dataobject}
> 
> 
>> On Mon, 2005-04-18 at 16:22 +0200, Jorg Heymans wrote:
>>
>>> I would like to do the following
>>>
>>> cocoon.sendPage("streamdata", {"dataobject" , data} );
>>>
>>> and then in the generator setup() of the streamdata pipeline somehow 
>>> grab this "dataObject" object.


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


Re: attaching an object to sendpage

Posted by Upayavira <uv...@upaya.co.uk>.
Or use the FlowHelper class.

Regards, Upayavira

Arsen A. Gutsal wrote:
> {flow-attribute:dataobject}

> On Mon, 2005-04-18 at 16:22 +0200, Jorg Heymans wrote:
>>I would like to do the following
>>
>>cocoon.sendPage("streamdata", {"dataobject" , data} );
>>
>>and then in the generator setup() of the streamdata pipeline somehow 
>>grab this "dataObject" object.

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


Re: attaching an object to sendpage

Posted by "Arsen A. Gutsal" <ar...@softsky.com.ua>.
{flow-attribute:dataobject}
On Mon, 2005-04-18 at 16:22 +0200, Jorg Heymans wrote:
> Hi,
> 
> I would like to do the following
> 
> cocoon.sendPage("streamdata", {"dataobject" , data} );
> 
> and then in the generator setup() of the streamdata pipeline somehow 
> grab this "dataObject" object.
> 
> 
> Regards
> Jorg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
-- 
Sincerely,
Arsen A. Gutsal
SOFTSKY Ltd CEO/Executive
SOFTSKY - Cost effective Software Development


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