Hi Thierry, try just configure your destination to use the custom java assembler, not the hibernate.
/r http://www.searchcoders.com/ On Wed, May 7, 2008 at 6:07 AM, tit0uill3 <[EMAIL PROTECTED]> wrote: > Hello group ! > > I would like to create my own custom assembler to retrieve some data > from database in xml format. I don't know if it's the better way to do > that, but I have some hibernate assemblers called in my application, > and don't want to complexify with other http or rpc services... Tell > me if I'm on the wrong way :)p > > So I create an assembler like this, just for tests : > > /** > * > */ > package com.neolinkup.app.vo; > > > import flex.data.assemblers.AbstractAssembler; > import flex.messaging.io.ArrayCollection; > > import java.io.ByteArrayInputStream; > import java.io.IOException; > > import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.DocumentBuilder; > import javax.xml.parsers.ParserConfigurationException; > > import org.xml.sax.InputSource; > import org.xml.sax.SAXException; > > > /** > * @author titouille > * > */ > public class RoomAssembler extends AbstractAssembler > { > public ArrayCollection fill() > { > String s = "<rooms>" + > "<cinema id='1' > label='cinema 1'>" + > "<room roomid='1' > label='room 1' />" + > "<room roomid='2' > label='room 2' />" + > "</cinema>" + > "</rooms>"; > > try > { > DocumentBuilderFactory docBuilderFactory = > DocumentBuilderFactory.newInstance(); > DocumentBuilder docBuilder = > docBuilderFactory.newDocumentBuilder(); > > ArrayCollection a = new ArrayCollection(); > a.add( docBuilder.parse( new InputSource( new > ByteArrayInputStream( > s.getBytes() ) ) ) ); > return a; > } > catch( ParserConfigurationException pce ) > { > System.out.println( "ERROR - > ParserConfigurationException: > getXmlDocument - " + pce.getMessage() ); > return null; > } > catch( SAXException saxe ) > { > System.out.println( "ERROR - SAXException: > getXmlDocument - " + > saxe.getMessage() ); > return null; > } > catch( IOException ioe ) > { > System.out.println( "ERROR - IOException: > getXmlDocument - " + > ioe.getMessage() ); > return null; > } > } > } > > and my destination : > > <destination id="roomvo.hibernate"> > <adapter ref="java-dao" /> > <properties> > <source>com.neolinkup.app.vo.RoomAssembler</source> > <scope>application</scope> > <metadata> > <identity property="roomid"/> > </metadata> > <network> > <session-timeout>20</session-timeout> > <paging enabled="false" pageSize="10" /> > <throttle-inbound policy="ERROR" > max-frequency="500"/> > <throttle-outbound policy="REPLACE" > max-frequency="500"/> > </network> > <server> > <fill-method> > <name>fill</name> > </fill-method> > </server> > </properties> > </destination> > > > And I try with a simple mxml application with : > > ds = new DataService( "roomvo.hibernate" ); > list = new ArrayCollection(); > > s.addEventListener( DataServiceFaultEvent.FAULT, this._handleFault ); > s.addEventListener( DataConflictEvent.CONFLICT, this._handleConflict ); > s.addEventListener(ResultEvent.RESULT, this._handleResult ); > s.fill( list ); > > But Flex return to me an error like this : > > ArgumentError: Items must support IManaged. See [Managed] for more > information: object: <rooms> > <cinema id="1" label="cinema 1"> > <room roomid="1" label="room 1"/> > <room roomid="2" label="room 2"/> > </cinema> > </rooms> with referencedIds [] > at > mx.data::ConcreteDataService/ > http://www.adobe.com/2006/flex/mx/internal::normalize()[C:\depot\flex\branches\enterprise_bridgeman\frameworks\mx\data\ConcreteDataService.as:2595]<http://www.adobe.com/2006/flex/mx/internal::normalize%28%29%5BC:%5Cdepot%5Cflex%5Cbranches%5Centerprise_bridgeman%5Cframeworks%5Cmx%5Cdata%5CConcreteDataService.as:2595%5D> > at > mx.data::DataList/ > http://www.adobe.com/2006/flex/mx/internal::processSequence()[C:\depot\flex\branches\enterprise_bridgeman\frameworks\mx\data\DataList.as:1597]<http://www.adobe.com/2006/flex/mx/internal::processSequence%28%29%5BC:%5Cdepot%5Cflex%5Cbranches%5Centerprise_bridgeman%5Cframeworks%5Cmx%5Cdata%5CDataList.as:1597%5D> > at > mx.data::DataList/ > http://www.adobe.com/2006/flex/mx/internal::processSequenceResult()[C:\depot\flex\branches\enterprise_bridgeman\frameworks\mx\data\DataList.as:1788]<http://www.adobe.com/2006/flex/mx/internal::processSequenceResult%28%29%5BC:%5Cdepot%5Cflex%5Cbranches%5Centerprise_bridgeman%5Cframeworks%5Cmx%5Cdata%5CDataList.as:1788%5D> > at > > DataListRequestResponder/result()[C:\depot\flex\branches\enterprise_bridgeman\frameworks\mx\data\ConcreteDataService.as:5857] > at > > mx.rpc::AsyncRequest/acknowledge()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74] > at > > NetConnectionMessageResponder/resultHandler()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:469] > at > > mx.messaging::MessageResponder/result()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:199] > > > If I try to return a dom document instead of an arrayCollection, lcds > return to me a casting error... > > Any suggestion about how to get some "read-only" XML data to fill a > tree with complex hierarchical data... I need java to get data from DB > and format it as XML, but don't know the better way to do it... If > anyone has a way or some informations, tutorials, etc... I'm very > interested. > > Thanks in advance. > > > Thierry aka titouille > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > Links > > > >

