You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Andre Juffer <aj...@sun3.oulu.fi> on 2005/04/02 09:53:11 UTC

Using business objects instead of XML

Dear List,

I am trying to insert a domain object into the pipiline with control 
flow following a suggestion given earlier on this list:

http://www.mail-archive.com/users@cocoon.apache.org/msg23293.html

Suppose, I return some object from a domain class instance, like

var domainObject = com.foo.myClass.doSomething();

The domainObject has all the getters available, e.g. getName(), etc, so 
it acts like a regular bean.

Now, I would like insert this object in the pipeline with

cocoon.sendPage ("page", domainObject);

In the sitemap, I have

<map:match pattern="page">
   <map:generate src="module:flow-attr:domainObject" />
   <map:serialize type="xml" />
</map:match>

(This is just to see how it looks like.)

The result of all this is an error of the form:

org.apache.cocoon.ProcessingException: Exception during source 
resolving.: org.apache.excalibur.source.SourceException: The attribute: 
domainObject is empty

This looks obvious to me, since it is probably not clear that the 
domainObject in facts represents some class, defined in com.foo.myClass. 
So, I tried to define the DomainObject class in JavaScripy, like

function DomainObject()
{
}
DomainObject.prototype.name;

and populate the object manually before calling cocoon.sendPage. The 
result is however the same.

I am using cocoon 2.1.7.

Could anyone point out in some detail how exactly I should do this.

Thanks,

-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/

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


Re: Using business objects instead of XML

Posted by Leszek Gawron <lg...@apache.org>.
Andre Juffer wrote:
> Leszek, and Others,
> 
> I have tried the following as well (flow script):
> 
> function DomainObject()
> {
> }
> DomainObject.prototype.id;
> DomainObject.prototype.name;
> 
> function something()
> {
>     ....
> 
>     // Get the request parameters.
>     var domainObject = new DomainObject();
>     domainObject.name = cocoon.request.getParameter("name");
>     domainObject.id = 1000;
>     cocoon.sendPage("page", { "DomainObject" : domainObject } );
> }
> 
> The result of this is
> 
> org.apache.cocoon.ProcessingException: Exception during source 
> resolving.: org.apache.excalibur.source.SourceException: The object 
> type: class org.mozilla.javascript.NativeObject could not be serialized 
> as a InputStream [object Object]
> 
> If I use one of my own domainObjects, that is, I have now
> 
> var domainObject = com.foo.SomeClass.doSomething()
> 
> the result is very similar:
> 
> org.apache.cocoon.ProcessingException: Exception during source 
> resolving.: org.apache.excalibur.source.SourceException: The object 
> type: class com.foo.DomainObject could not be serialized as a 
> InputStream DomainObject - name: jfifiikss, id: 1000
> 
> (The last line is produced by the toString() method of the 
> com.foo.DomainObject class.)
> 
> So, the key problem is that objects cannot be serialized as an 
> InputStream for the pipeline, which occurs at
> 
> <map:generate src="module:flow-attr:DomainObject" />
> 
> in the sitemap.
> 
> Anybody any ideas about this? The basic question here is how exactly one 
> can process objects instantiated in a flowscrip by the sitemap?
> 
> (Cocoon version 2.1.7)
> 
> Thanks,
> Andre.
> 
> Leszek Gawron wrote:
> 
>> Andre Juffer wrote:
>>
>>> Dear List,
>>>
>>> I am trying to insert a domain object into the pipiline with control 
>>> flow following a suggestion given earlier on this list:
>>>
>>> http://www.mail-archive.com/users@cocoon.apache.org/msg23293.html
>>>
>>> Suppose, I return some object from a domain class instance, like
>>>
>>> var domainObject = com.foo.myClass.doSomething();
>>>
>>> The domainObject has all the getters available, e.g. getName(), etc, 
>>> so it acts like a regular bean.
>>>
>>> Now, I would like insert this object in the pipeline with
>>>
>>> cocoon.sendPage ("page", domainObject);
>>
>>
>> try:
>> cocoon.sendPage( "page", { "domainObject" : domainObject } );
>> If you pass it as you previously did your domain object is the main 
>> context. flow-attr:domainObject looks for an object "domainObject" in 
>> main context so in fact in your case it queries for 
>> /domainObject/domainObject which is incorrect
>>
>>>
>>> In the sitemap, I have
>>>
>>> <map:match pattern="page">
>>>   <map:generate src="module:flow-attr:domainObject" />
>>>   <map:serialize type="xml" />
>>> </map:match>
>>
>>
>>
>>>
>>> (This is just to see how it looks like.)
>>>
>>> The result of all this is an error of the form:
>>>
>>> org.apache.cocoon.ProcessingException: Exception during source 
>>> resolving.: org.apache.excalibur.source.SourceException: The 
>>> attribute: domainObject is empty
>>>
>>> This looks obvious to me, since it is probably not clear that the 
>>> domainObject in facts represents some class, defined in 
>>> com.foo.myClass. So, I tried to define the DomainObject class in 
>>> JavaScripy, like
>>>
>>> function DomainObject()
>>> {
>>> }
>>> DomainObject.prototype.name;
>>>
>>> and populate the object manually before calling cocoon.sendPage. The 
>>> result is however the same.
>>>
>>> I am using cocoon 2.1.7.
The easiest thing I can advice you now is to define the domain entity as 
java class and implement Xmlizable. Then you have to define your entity 
"xml behaviour" in toSax method.

then do:
<map:match pattern="page">
<!-- note the xmodule!! -->
    <map:generate src="xmodule:flow-attr:domainObject" />
    <map:serialize type="xml" />
</map:match>

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65
-- 
Leszek Gawron                                                 MobileBox
lgawron@apache.org                              http://www.mobilebox.pl

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


Re: Using business objects instead of XML

Posted by Andre Juffer <aj...@sun3.oulu.fi>.
Leszek, and Others,

I have tried the following as well (flow script):

function DomainObject()
{
}
DomainObject.prototype.id;
DomainObject.prototype.name;

function something()
{
     ....

     // Get the request parameters.
     var domainObject = new DomainObject();
     domainObject.name = cocoon.request.getParameter("name");
     domainObject.id = 1000;
     cocoon.sendPage("page", { "DomainObject" : domainObject } );
}

The result of this is

org.apache.cocoon.ProcessingException: Exception during source 
resolving.: org.apache.excalibur.source.SourceException: The object 
type: class org.mozilla.javascript.NativeObject could not be serialized 
as a InputStream [object Object]

If I use one of my own domainObjects, that is, I have now

var domainObject = com.foo.SomeClass.doSomething()

the result is very similar:

org.apache.cocoon.ProcessingException: Exception during source 
resolving.: org.apache.excalibur.source.SourceException: The object 
type: class com.foo.DomainObject could not be serialized as a 
InputStream DomainObject - name: jfifiikss, id: 1000

(The last line is produced by the toString() method of the 
com.foo.DomainObject class.)

So, the key problem is that objects cannot be serialized as an 
InputStream for the pipeline, which occurs at

<map:generate src="module:flow-attr:DomainObject" />

in the sitemap.

Anybody any ideas about this? The basic question here is how exactly one 
can process objects instantiated in a flowscrip by the sitemap?

(Cocoon version 2.1.7)

Thanks,
Andre.

Leszek Gawron wrote:
> Andre Juffer wrote:
> 
>> Dear List,
>>
>> I am trying to insert a domain object into the pipiline with control 
>> flow following a suggestion given earlier on this list:
>>
>> http://www.mail-archive.com/users@cocoon.apache.org/msg23293.html
>>
>> Suppose, I return some object from a domain class instance, like
>>
>> var domainObject = com.foo.myClass.doSomething();
>>
>> The domainObject has all the getters available, e.g. getName(), etc, 
>> so it acts like a regular bean.
>>
>> Now, I would like insert this object in the pipeline with
>>
>> cocoon.sendPage ("page", domainObject);
> 
> try:
> cocoon.sendPage( "page", { "domainObject" : domainObject } );
> If you pass it as you previously did your domain object is the main 
> context. flow-attr:domainObject looks for an object "domainObject" in 
> main context so in fact in your case it queries for 
> /domainObject/domainObject which is incorrect
> 
>>
>> In the sitemap, I have
>>
>> <map:match pattern="page">
>>   <map:generate src="module:flow-attr:domainObject" />
>>   <map:serialize type="xml" />
>> </map:match>
> 
> 
>>
>> (This is just to see how it looks like.)
>>
>> The result of all this is an error of the form:
>>
>> org.apache.cocoon.ProcessingException: Exception during source 
>> resolving.: org.apache.excalibur.source.SourceException: The 
>> attribute: domainObject is empty
>>
>> This looks obvious to me, since it is probably not clear that the 
>> domainObject in facts represents some class, defined in 
>> com.foo.myClass. So, I tried to define the DomainObject class in 
>> JavaScripy, like
>>
>> function DomainObject()
>> {
>> }
>> DomainObject.prototype.name;
>>
>> and populate the object manually before calling cocoon.sendPage. The 
>> result is however the same.
>>
>> I am using cocoon 2.1.7.
>>
>> Could anyone point out in some detail how exactly I should do this.
>>
>> Thanks,
>>
> 
> 


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/

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


Re: Using business objects instead of XML

Posted by Andre Juffer <An...@oulu.fi>.
Ralph Goers wrote:
> Leszek Gawron wrote:
> 
>>>  you can of course use castor generator but I do not know if castor 
>>> is able to generate anything if it has no mapping file.
>>
>>
>>
> We use a "Bean Generator" that I wrote that uses Betwixt.  It is just a 
> few lines of code.  If the objects are faily "well behaved" then the XML 
> produced is pretty good. It doesn't need a mapping file.

Thanks. Just checked out the Betwixt website. Looks very simple and 
certainly worth trying.

Andre

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


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/

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


Re: Using business objects instead of XML

Posted by Ralph Goers <Ra...@dslextreme.com>.
Leszek Gawron wrote:

>>  you can of course use castor generator but I do not know if castor 
>> is able to generate anything if it has no mapping file.
>
>
We use a "Bean Generator" that I wrote that uses Betwixt.  It is just a 
few lines of code.  If the objects are faily "well behaved" then the XML 
produced is pretty good. It doesn't need a mapping file.

Ralph


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


Re: Using business objects instead of XML

Posted by Andre Juffer <aj...@sun3.oulu.fi>.
Leszek Gawron wrote:
> Andre Juffer wrote:
> 
>> Leszek Gawron wrote:
>>
>>> Andre Juffer wrote:
>>>
>>>> Leszek Gawron wrote:
>>>>
>>>>>
>>>>> There is no way for the generator to know how xml can be generated 
>>>>> out of your domain object. There is no possibility to do that 
>>>>> without "helping" the framework. I do not know what is expected 
>>>>> from source to be xmlizable. I would have to look into the sources. 
>>>>> Or even better do it yourself - you'll get a better knowledge of 
>>>>> how cocoon works.
>>>>>
>>>>>
>>>>
>>>> Yes, I thought already that it would go in that direction. I was 
>>>> hoping that reflection was used to get information about a class 
>>>> (e.g. as in Castor).
>>>
>>>
>>>
>>> you can of course use castor generator but I do not know if castor is 
>>> able to generate anything if it has no mapping file.
> 
> I meant transformer
> 
>>
>>
>> Actually, it can, it will use reflection, at least the documentation 
>> tells so:
>>
>> "Castor can marshal "almost" any arbitrary Object to and from XML. 
>> When descriptors are not available for a specfic Class, the 
>> marshalling framework uses reflection to gain information about the 
>> object."
>>
>> see http://castor.codehaus.org/xml-framework.html
>>
>> It does require that the object implements the java.io.Serializable 
>> interface, though, implying that one has to change the relevant 
>> DomainObject class (or extend them to create cocoon/castor specific 
>> classes).
> 
> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/transformation/CastorTransformer.html

Yes, this is the Transformer as provided by cocoon, which requires field 
descriptors. However, the 'original' Castor can handle this all also 
without descriptors using reflection. It is trivial of course to include 
a separate descriptor file, so it seems that the CastorTransformer could 
be a good choice. Thanks for the tip (I apprently overlooked this 
Transformer)

> 
> 
> 


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/

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


Re: Using business objects instead of XML

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Andre Juffer wrote:
> Leszek Gawron wrote:
> 
>> Andre Juffer wrote:
>>
>>> Leszek Gawron wrote:
>>>
>>>>
>>>> There is no way for the generator to know how xml can be generated 
>>>> out of your domain object. There is no possibility to do that 
>>>> without "helping" the framework. I do not know what is expected from 
>>>> source to be xmlizable. I would have to look into the sources. Or 
>>>> even better do it yourself - you'll get a better knowledge of how 
>>>> cocoon works.
>>>>
>>>>
>>>
>>> Yes, I thought already that it would go in that direction. I was 
>>> hoping that reflection was used to get information about a class 
>>> (e.g. as in Castor).
>>
>>
>> you can of course use castor generator but I do not know if castor is 
>> able to generate anything if it has no mapping file.
I meant transformer

> 
> 
> Actually, it can, it will use reflection, at least the documentation 
> tells so:
> 
> "Castor can marshal "almost" any arbitrary Object to and from XML. When 
> descriptors are not available for a specfic Class, the marshalling 
> framework uses reflection to gain information about the object."
> 
> see http://castor.codehaus.org/xml-framework.html
> 
> It does require that the object implements the java.io.Serializable 
> interface, though, implying that one has to change the relevant 
> DomainObject class (or extend them to create cocoon/castor specific 
> classes).
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/transformation/CastorTransformer.html


-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

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


Re: Using business objects instead of XML

Posted by Andre Juffer <aj...@sun3.oulu.fi>.
Leszek Gawron wrote:
> Andre Juffer wrote:
> 
>> Leszek Gawron wrote:
>>
>>>
>>> There is no way for the generator to know how xml can be generated 
>>> out of your domain object. There is no possibility to do that without 
>>> "helping" the framework. I do not know what is expected from source 
>>> to be xmlizable. I would have to look into the sources. Or even 
>>> better do it yourself - you'll get a better knowledge of how cocoon 
>>> works.
>>>
>>>
>>
>> Yes, I thought already that it would go in that direction. I was 
>> hoping that reflection was used to get information about a class (e.g. 
>> as in Castor).
> 
> you can of course use castor generator but I do not know if castor is 
> able to generate anything if it has no mapping file.

Actually, it can, it will use reflection, at least the documentation 
tells so:

"Castor can marshal "almost" any arbitrary Object to and from XML. When 
descriptors are not available for a specfic Class, the marshalling 
framework uses reflection to gain information about the object."

see http://castor.codehaus.org/xml-framework.html

It does require that the object implements the java.io.Serializable 
interface, though, implying that one has to change the relevant 
DomainObject class (or extend them to create cocoon/castor specific 
classes).

-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/

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


Re: Using business objects instead of XML

Posted by Leszek Gawron <lg...@apache.org>.
Andre Juffer wrote:
> Leszek Gawron wrote:
> 
>>
>> There is no way for the generator to know how xml can be generated out 
>> of your domain object. There is no possibility to do that without 
>> "helping" the framework. I do not know what is expected from source to 
>> be xmlizable. I would have to look into the sources. Or even better do 
>> it yourself - you'll get a better knowledge of how cocoon works.
>>
>>
> 
> Yes, I thought already that it would go in that direction. I was hoping 
> that reflection was used to get information about a class (e.g. as in 
> Castor).
you can of course use castor generator but I do not know if castor is 
able to generate anything if it has no mapping file.

-- 
Leszek Gawron                                                 MobileBox
lgawron@apache.org                              http://www.mobilebox.pl

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


Re: Using business objects instead of XML

Posted by Andre Juffer <aj...@sun3.oulu.fi>.
Leszek Gawron wrote:
> 
> There is no way for the generator to know how xml can be generated out 
> of your domain object. There is no possibility to do that without 
> "helping" the framework. I do not know what is expected from source to 
> be xmlizable. I would have to look into the sources. Or even better do 
> it yourself - you'll get a better knowledge of how cocoon works.
> 
> 

Yes, I thought already that it would go in that direction. I was hoping 
that reflection was used to get information about a class (e.g. as in 
Castor).

Thanks for your help.

-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/

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


Re: Using business objects instead of XML

Posted by Leszek Gawron <lg...@apache.org>.
Andre Juffer wrote:
> Leszek Gawron wrote:
> 
>> Andre Juffer wrote:
>>
>>> Dear List,
>>>
>>> I am trying to insert a domain object into the pipiline with control 
>>> flow following a suggestion given earlier on this list:
>>>
>>> http://www.mail-archive.com/users@cocoon.apache.org/msg23293.html
>>>
>>> Suppose, I return some object from a domain class instance, like
>>>
>>> var domainObject = com.foo.myClass.doSomething();
>>>
>>> The domainObject has all the getters available, e.g. getName(), etc, 
>>> so it acts like a regular bean.
>>>
>>> Now, I would like insert this object in the pipeline with
>>>
>>> cocoon.sendPage ("page", domainObject);
>>
>>
>> try:
>> cocoon.sendPage( "page", { "domainObject" : domainObject } );
>> If you pass it as you previously did your domain object is the main 
>> context. flow-attr:domainObject looks for an object "domainObject" in 
>> main context so in fact in your case it queries for 
>> /domainObject/domainObject which is incorrect
> 
> 
> I see. I tried and indeed this gives a different result. At least, I can 
>  now see some values. The error message is now
> 
> org.apache.cocoon.ProcessingException: Exception during source 
> resolving.: org.apache.excalibur.source.SourceException: The object 
> type: class com.foo.DomainObject could not be serialized as a 
> InputStream DomainObject - name: jfifiikss, id: -1977936240, author: FOO
> 
> This is caused by the class com.foo.DomainObject itself.
> 
>>
>>>
>>> In the sitemap, I have
>>>
>>> <map:match pattern="page">
>>>   <map:generate src="module:flow-attr:domainObject" />
>>>   <map:serialize type="xml" />
>>> </map:match>
>>
>>
>>
>>>
>>> (This is just to see how it looks like.)
>>>
>>> The result of all this is an error of the form:
>>>
>>> org.apache.cocoon.ProcessingException: Exception during source 
>>> resolving.: org.apache.excalibur.source.SourceException: The 
>>> attribute: domainObject is empty
>>>
>>> This looks obvious to me, since it is probably not clear that the 
>>> domainObject in facts represents some class, defined in 
>>> com.foo.myClass. So, I tried to define the DomainObject class in 
>>> JavaScripy, like
>>>
>>> function DomainObject()
>>> {
>>> }
>>> DomainObject.prototype.name;
>>>
>>> and populate the object manually before calling cocoon.sendPage. The 
>>> result is however the same.
>>>
>>> I am using cocoon 2.1.7.
>>>
>>> Could anyone point out in some detail how exactly I should do this.
>>>
>>> Thanks,
There is no way for the generator to know how xml can be generated out 
of your domain object. There is no possibility to do that without 
"helping" the framework. I do not know what is expected from source to 
be xmlizable. I would have to look into the sources. Or even better do 
it yourself - you'll get a better knowledge of how cocoon works.


-- 
Leszek Gawron                                                 MobileBox
lgawron@apache.org                              http://www.mobilebox.pl

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


Re: Using business objects instead of XML

Posted by Andre Juffer <aj...@sun3.oulu.fi>.
Leszek Gawron wrote:
> Andre Juffer wrote:
> 
>> Dear List,
>>
>> I am trying to insert a domain object into the pipiline with control 
>> flow following a suggestion given earlier on this list:
>>
>> http://www.mail-archive.com/users@cocoon.apache.org/msg23293.html
>>
>> Suppose, I return some object from a domain class instance, like
>>
>> var domainObject = com.foo.myClass.doSomething();
>>
>> The domainObject has all the getters available, e.g. getName(), etc, 
>> so it acts like a regular bean.
>>
>> Now, I would like insert this object in the pipeline with
>>
>> cocoon.sendPage ("page", domainObject);
> 
> try:
> cocoon.sendPage( "page", { "domainObject" : domainObject } );
> If you pass it as you previously did your domain object is the main 
> context. flow-attr:domainObject looks for an object "domainObject" in 
> main context so in fact in your case it queries for 
> /domainObject/domainObject which is incorrect

I see. I tried and indeed this gives a different result. At least, I can 
  now see some values. The error message is now

org.apache.cocoon.ProcessingException: Exception during source 
resolving.: org.apache.excalibur.source.SourceException: The object 
type: class com.foo.DomainObject could not be serialized as a 
InputStream DomainObject - name: jfifiikss, id: -1977936240, author: FOO

This is caused by the class com.foo.DomainObject itself.

> 
>>
>> In the sitemap, I have
>>
>> <map:match pattern="page">
>>   <map:generate src="module:flow-attr:domainObject" />
>>   <map:serialize type="xml" />
>> </map:match>
> 
> 
>>
>> (This is just to see how it looks like.)
>>
>> The result of all this is an error of the form:
>>
>> org.apache.cocoon.ProcessingException: Exception during source 
>> resolving.: org.apache.excalibur.source.SourceException: The 
>> attribute: domainObject is empty
>>
>> This looks obvious to me, since it is probably not clear that the 
>> domainObject in facts represents some class, defined in 
>> com.foo.myClass. So, I tried to define the DomainObject class in 
>> JavaScripy, like
>>
>> function DomainObject()
>> {
>> }
>> DomainObject.prototype.name;
>>
>> and populate the object manually before calling cocoon.sendPage. The 
>> result is however the same.
>>
>> I am using cocoon 2.1.7.
>>
>> Could anyone point out in some detail how exactly I should do this.
>>
>> Thanks,
>>
> 
> 


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/

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


Re: Using business objects instead of XML

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Andre Juffer wrote:
> Dear List,
> 
> I am trying to insert a domain object into the pipiline with control 
> flow following a suggestion given earlier on this list:
> 
> http://www.mail-archive.com/users@cocoon.apache.org/msg23293.html
> 
> Suppose, I return some object from a domain class instance, like
> 
> var domainObject = com.foo.myClass.doSomething();
> 
> The domainObject has all the getters available, e.g. getName(), etc, so 
> it acts like a regular bean.
> 
> Now, I would like insert this object in the pipeline with
> 
> cocoon.sendPage ("page", domainObject);
try:
cocoon.sendPage( "page", { "domainObject" : domainObject } );
If you pass it as you previously did your domain object is the main 
context. flow-attr:domainObject looks for an object "domainObject" in 
main context so in fact in your case it queries for 
/domainObject/domainObject which is incorrect

> 
> In the sitemap, I have
> 
> <map:match pattern="page">
>   <map:generate src="module:flow-attr:domainObject" />
>   <map:serialize type="xml" />
> </map:match>

> 
> (This is just to see how it looks like.)
> 
> The result of all this is an error of the form:
> 
> org.apache.cocoon.ProcessingException: Exception during source 
> resolving.: org.apache.excalibur.source.SourceException: The attribute: 
> domainObject is empty
> 
> This looks obvious to me, since it is probably not clear that the 
> domainObject in facts represents some class, defined in com.foo.myClass. 
> So, I tried to define the DomainObject class in JavaScripy, like
> 
> function DomainObject()
> {
> }
> DomainObject.prototype.name;
> 
> and populate the object manually before calling cocoon.sendPage. The 
> result is however the same.
> 
> I am using cocoon 2.1.7.
> 
> Could anyone point out in some detail how exactly I should do this.
> 
> Thanks,
> 


-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

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