cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <lgaw...@apache.org>
Subject Re: Using business objects instead of XML
Date Sat, 02 Apr 2005 20:07:14 GMT
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


Mime
View raw message