Skip to main content

Posts

Convert XML to ArrayCollection

If you have an XML and want to use it in the spark's list component, than you need to first convert it into ArrayCollection and that's what we are doing in this example: Lets assume you have following XML: varstrXML:XML = <blog>         < item>               <title>Blog by Subodh Gupta                < author>Subodh Guptaauthor >        < /item> </blog> ; var xml:XML = new XML(strXML); var xmlDoc:XMLDocument = new XMLDocument(xml); var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true); var resultObj:Object = decoder.decodeXML(xmlDoc); var ac:ArrayCollection ; if(resultObj. blog .hasOwnProperty(" item ")) {       if(resultObj. blog . item is ArrayCollection)       {       ac = resultObj.root.element; } } that's it you are done. ...

Divide and Conquer by Java Threads

Suppose you have task which collects the data the from various sources and creates a Object containing all this information e.g. information is distributes over various databases, websites and some you need to calculate based on that data. The single threaded application works fine with small amount of data however as data starts growing single threads shows its limitation. There is a interesting property of threads which comes to our rescue. Thread maintains the private copy of object on which it operates called as w orking copy in which it keeps the local modification which are made to the object. While main memory contains the master copy of every object. After all threads stop executing all the working copies are merged into the master copy. This becomes the curse in case of multiple objects modify the same field in the object because merging back creates the confusion and results in a unpredictable behavior. However if each thread works on the different field of the object me...

Cool solution for Cross domain

Just follow these steps to make it work: Compose your response as an JSON let say responseObject variable represent this JSON string/object Wrap the JSON response as an argument to a method call e.g. helloMethod (responseObject); where helloMethod is the method name Define this method( helloMethod ) which handles this response in the client side Lets take complete working sample: assume JSON Object as str = {"user":{"fname":"subodh","lname":"gupta","type":"blog","category":"tech"}} handleUser(str); function handleUser(str){ alert(str.user.fname);} just to complete the solution look at call below: jQuery.getJSON("http://subodh.blog.com/servlet?user=subodh&responseType=JSON", function(str) {     alert(str.user.fname); }); Look at this link for details jQuery.getJSON . http://subodh.blog.com/servlet?user=subodh&responseType=JSON this could be replaced by your serv...

Problem/Limitation in using flXHR

I had a cross domain issue and after browsing for a while i came across flXHR which seemed to be promising solution and hence i went ahead with it. It's a flash based cross domain solution which is based on a crossdomain.xml config file (which lists the list of sites from where you can access the services). For more details on flXHR click here. I thought I have the great solution in hand and work with it before I encountered thee major of limitation of flXHR:  The location of crossdomain.xml can be specified in configuration of flproxy via loadPolicyURL attribute. Which is supposedly the path flXHR will take to resolve the permission of your domain to access service hosted at that domain. However this is where the problem comes it will not only consider the crossdomain.xml at given location but it will also make a query at the root of the site and hunt gain for crossdomain.xml to see the permission for the client domain to access the service e.g. if you specify loadPolicyURL=ww...

Prototype and jQuery together…

How to make prototype.js and jquery.js work together….? Answer is in fact very simple and indeed jquery did it all for you already following is the code snippet on how to do it: <script src=”.../prototype.js></script> <script src=”.../jquery.js></script> <script>jQuery.noConflict();</script> and replace your $ of jQuery with jQuery that it guys you are good to go :)

flXHR and JQuery IE 7 crash

I am using the cross domain flXHR solution with jQuery well initially it was a headache to implement but once done it was on auto pilot seems liked a gem until recently when i got the blocker of IE7 crash on windows XP. The problem seems to be caused by swfobject.js and putting it before jquery declaration will solve the problem:             <script type="text/javascript" src="/flXHR/swfobject.js"/>             <script type="text/javascript" src="/flXHR/flXHR.js"/>

flXHR Error:15, securityError, A security sandbox error occured with the flXHR request.

Error: 15 Type: securityError Description: A security sandbox error occured with the flXHR request. Source Object Id: [your object id] I am trying to deploy my application on Tomcat and was continuously facing the issue. The solution to this problem is placing your crossdomain.xml in /webapps/ROOT. Just for reference attaching the sample crossdomain.xml on which I was working trying to workout my PoC:   <?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <site-control permitted-cross-domain-policies="master-only"/> <allow-access-from domain="*" secure="false"/> <allow-http-request-headers-from domain="*" headers="*" secure="false"/> </cross-domain-policy> Hope this will help.