PDA

View Full Version : POJOs over XML


maxim.porges
06-01-2005, 08:33 PM
I'm relatively new to Laszlo, and having recently sussed out the Java/RPC capabilities, I'm interested in creating a Laszlo application that uses objects instead of XML.

My intent is to create a service layer object that exposes service methods to Laszlo. Behind the scenes, this service layer object would wrap calls to my object model. Data would be returned to Laszlo as POJOs, and Laszlo would render its views and act upon the data returned from the service layer by retrieving individual data fields from the POJOs. When passing data to the service layer, method calls would be made against it using data collected by forms on the client application.

I have a few questions.

1) Would this method of working be considered bad practice? Everything I am reading about Laszlo (especially in the tutorials) seems to push using XML as the data format. However, constantly swizzling to XML strikes me as a lot of extra work if I already have POJOs available, especially with RPC being as simple to implement as it is in Laszlo.

2) How would I perform an operation such as iterating over an array of objects returned from the service layer? With XML, this is easily achieved using the <view> tag and an XPath expression in the datapath attribute, but I could see no equivalent for object collections or arrays. I considered writing my own view extension tag that can iterate objects; would this be a suitable alternative if no pre-existing solution is available?

3) Is anybody else purely using Java objects instead of XML in their Laszlo applications? If so, what have your experiences been, and what are your recommendations/cautions for this approach?

4) Is it possible to write my own Laszlo classes that will perform data binding to an object collection of some type, similar to the XML binding available when using datasets?

5) I know I can retrieve POJOs from RPC, but is it possible to instantiate POJO objects locally to send them back up the pipe to the service layer on the server over RPC? (Sorry, being lazy on this one... I know I could just try it out, but it's almost bedtime - so I'll just ask the experts :) ).

I'm looking forward to your responses and experiences as I delve deeper in to Laszlo!

Thanks,

- max

maxim.porges
06-01-2005, 09:33 PM
Hmm... looks like I should have read this chapter (RPC in general) before jumpinng straight in to the Java/RPC chapter... :)

http://www.laszlosystems.com/lps-2.2/docs/guide/rpc.html

My initial understanding of this info is that Laszlo can easily convert simple objects to XML for databinding purposes, and it appears that it can bind data from objects back to XML for relaying back to the server over RPC... is this correct?

Either way, I'm still interested in opinions on the questions I posted, and finding out if anybody can share their RPC experiences.

- max

jasonj
08-25-2005, 12:34 PM
I too am trying to figure out how to use the standard binding (aka datapath) mechanism to "attach" to a script object instead of an XML node. I find it easier to create and use objects (so I can add derived attributes, etc.) in lieu of XML.

ummm... perhaps we could add our own attribute to the view(s) (like "binding") and then loop through them on a save/submit type of action.

Anyone out there know the best way to do this?

thanks,
Jason

washington
12-28-2005, 10:43 AM
Hi my name's Luiz, did you found the answers to this questions? Because I still dont know.

Originally posted by maxim.porges
Hmm... looks like I should have read this chapter (RPC in general) before jumpinng straight in to the Java/RPC chapter... :)

http://www.laszlosystems.com/lps-2.2/docs/guide/rpc.html

My initial understanding of this info is that Laszlo can easily convert simple objects to XML for databinding purposes, and it appears that it can bind data from objects back to XML for relaying back to the server over RPC... is this correct?

Either way, I'm still interested in opinions on the questions I posted, and finding out if anybody can share their RPC experiences.

- max