HTTPService and JSON

I'm trying to get dynamic data in my tables using mx:HTTPService to get a JSON. I used the help of flex 3 and combed the forums to get this far, but I'm stuck now.
Here is my code
Quote:

<? XML version = "1.0" encoding = "utf-8"? >
"" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' layout = "absolute" viewSourceURL="srcview/index.html"preinitialize="srv.send (); ">

< mx:Script >
<! [CDATA]

Import mx.collections.ArrayCollection;
Import mx.rpc.events.ResultEvent;
import com.adobe.serialization.json.JSON;
Import mx.controls.Alert;
Import mx.utils.ObjectUtil;

[Bindable]
private var expensesAC:ArrayCollection = new ArrayCollection ([] collection
{time: '1-24 19:00 ', cal: 2000, VAT: 1500},.
([{time: '1-24 20:00 ', cal: 1000, VAT: 200}]) ;

private void onJSONLoad(event:ResultEvent):void {}
Alert.Show ("onJSONLoad called!");
var myData:String = String (event.result.DATA);
Alert.Show ("data has worked");

Alert.Show (mydata);
myText.text = myData;
ary var: Array = (JSON.decode (myData) in the table);
var dp:ArrayCollection = new ArrayCollection (ary.data);
linechart.dataProvider = dp;
}

private function failed (): void {}
Alert.Show ("fail!");
}

[]] > < / mx:Script >

<!--SERVICE HTTP-->
< mx:HTTPService id = "srv" resultFormat = "text" showBusyCursor = "true".
URL = ""--MySever-/ readings.jsp ' "
"result =" onJSONLoad (Event) "fault =" failed () "/ >


<!-CHART STUFF below - >
< mx:TextArea id = "myText" y = "310" width = "600" height = "250" / >
< mx:Panel title = "ISO requires hourly" height = "300" width = "600" layout = "horizontal" >
< mx:LineChart id = 'linechart' showDataTips = "true" dataProvider = "{expensesAC}" >
< mx:horizontalAxis >
< mx:CategoryAxis categoryField = "time" / >
< / mx:horizontalAxis >
< mx:series >
"" < mx:LineSeries yField = "cal" form = "curve" displayName = "Calforina" / >
< mx:LineSeries yField = form 'VAT' = 'segment' displayName = 'VAT' / >
< / mx:series >
< / mx:LineChart >
< / mx:Panel >
< / mx:Application >

Tags: Adobe LiveCycle

Similar Questions

  • corelib and JSON woes

    I want to serialize the data in a collection of ArrayCollection using JSON. Unfortunately, I get a stack when I try and JSON.encode () time-out error a table. I tried to use the ArrayCollection.toArray () and I tried to create just a simple array of objects. I can't make it work.

    If I do this: JSON.encode ({prop1: "Hello", prop2: "hello"}); It works very well.

    What I am doing wrong? Anyone know?

    BTW, I'm not entirely sure I linked the library properly. I couldn't find the great examples. What I did add < path element - >... bin/corelib / < / path element > my file flex - config.xml and added import com.adobe.serialization.json.JSON; my script.

    PS. I don't have Flex Builder. I use the command line compiler.

    It turns out that it was a problem with my table. I have a loop in an XMLList to build the table.

    Here is how I was building, inside the event of result for a HTTPService:

    var xmlList:XMLList = event.result.caption;
    for each {(var xml in xmlList)
    myArrayCollection.addItem ({id: xml. @id, text:xml.text, time: xml.time})
    }

    The JSON encoder is stuffy on the properties of the object types (I don't know what they are, I haven't looked. Maybe text nodes XML?). Values of type casting the xml code, everything works correctly:

    var xmlList:XMLList = event.result.caption;
    for each {(var xml in xmlList)
    myArrayCollection.addItem ({id:String (xml.@id), text:String (xml.text), time: String (xml.time)})
    }

    Thanks for the argument to the compiler. It is more flexible than the change in the configuration file.

  • HttpService with JSON server - help please

    Hello!
    I'm moving in return a JSON object in flex using HttpService. The scenario is like this - using HttpService I call an action as I am using Struts 2.0. This action is supposed to return a string in JSON format. When I pass in return the data as XML data is displayed correctly with the structure hierarchail. But when I pass the JSON string back it does not display anything.

    This is the call to the server
    < mx:HTTPService id = "srv" url = "... / myaction/getSomeData.action"/ > "

    the value of srv is coming with a null value.

    I am a total newbie to Flex.

    Thanks for any help in advance.
    Rohit

    First, you will need to read your response as a simple text by specifying resultFormat = "text" in your service:

    http://192.168.103.128:8081/ManageMe/manageme/generateXMLForGantt.action"resultFormat ="text"/ >

    Now in your result event you read the answer in the form of simple text:

    var rawData:String = String (event.result);

    Of course, now, you must encode the string as a JSON object. Flex is not a built-in JSON encoder/decoder. So here's the library done by Adobe/Flex people than hanldes JSON:

    http://code.Google.com/p/AS3corelib/

    Once you have downloaded this library and you copied into your lib foleder, the following line would look like:

    try {}
    Alert.Show (rawData);
    var o: Object = JSON.decode (rawData);
    Alert.Show (o ['baselineEnd']);

    }
    {catch(e:Error)})
    handle the error
    }

    should work!

    ATTA

  • Using the API with Edge (JQuery and JSON)

    Hi, I am very new to the API but I have a pretty basic understanding and I want to know how I could use them at the border. I followed the following tutorial and we tried to change it to my taste: http://www.gotoandlearn.com/play.php?id=168

    Basically, I'm going to pull in the latest photos from Flickr on Flickr.com. See my files in the Zip file below and the URL I have tested on:

    http://DL.dropbox.com/u/9159616/Flickr-test.zip

    http://createmate.co/Flickr-test/

    Thanks for your help!

    ADA,

    Hi Adam,.

    So, I downloaded your project files and I tested with another address of flickr.

    My test comes from: http://api.jquery.com/jQuery.getJSON/

    The code tested using your "slide" symbol, was:

    $.getJSON ("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",

    {

    Tags: "mount rainier"

    tagmode: 'all',

    format: 'json '.

    },

    {function (Data)}

    .each $(data.items, {function(i,item)}

    var s = sym.createChildSymbol ("slide", "Stage");

    s. $("photo") .css ({'background-image': ' url ('"+ item.media.m +" "") "});

    s.$("title").html (Item.title);

    If (I == 10) return false;

    });

    });

    Your symbol of slide works very well.

    Therefore, your flickr address is not correct.

    If you copy and paste your flickr address in your address bar (Safari), Flickr returns: jsonFlickrApi ({"stat": "fail", "code": 98, "message": "invalid authentication token"})

    You can check out this tutorial: r-api http://net.tutsplus.com/tutorials/javascript-ajax/the-ultimate-guide-to-decoding-the-flick /

  • Multi and Flex HTTPService and PHP user access

    Hello

    I'm developing a Flex with PHP application as a technology of the side server. I use HTTPService to send and receive data at and fom PHP. When I want to get a result, I send the request to a specific URL of PHP and manage the result in the Resut the HTTP Service event, which is in the form of an XML th. The problem is that if more than 1 user tries to perform the same operation at the same time, then the result is to be send to the same PHP url. But each user may have requested the URL in a different way. So, how can I check the result sent to a user is identical to what he prayed for and is not in conflict with another user.

    No, they won't, it's the same thing as you when you browse the internet, your ISP must have thousands of users, but when you ask forums.adobe.com you will get this site, not what your neighbor has asked. It's like a phone call when you dial a number, it rings and then someone answers you, is a one to one conversation.

  • Image and JSON response is possible with mapviewer

    Hello
    I am a newbie to mapviewer, however I have good skills with Open Source such as Geoserver map server, recently the data store has really exceeded the limits of my Architecture of Web mapping and nowadays I am bussy assess Mapviewer.

    I read the manual of the API and perform all demos, I think its fantastic, but in my scenario, I need to use without the javascript Api Maps Oralce mapviewer. It is possible to get an answer simple image when WMS calls ask and it is possible to get a JSON response agaisnt WFS request, because I use my web application and map server are in different domains, in order to avoid the same origin policy, I used JSON to my answers WFS. These two things are possible, in mapviewer or is it mandatory to use mapviewer with oracle map api.

    Kind regards.
    Imran

    WMS returns an image. WFS returns a xml (GML) doc as a response.
    JSON is not supported in the current version.

  • HTTPService and value chain.

    We experience an unexpected problem in our application. Is one of the tags returned by a HTTPService:

    < lot_code > 7E00024 < / lot_code >

    And bind us it to a column of data using grid:

    < mx:DataGridColumn headerText = "Number of batch" dataField = "lot_code" / >

    But the value displayed is:

    7F + 24

    If Flex is automatically converted to a number and showing in exponential format. How to set the XML to get us a value 'string' or 'text '?

    Thanks in advance.

    Hello
    How do you get your data?
    as E4X, XML, OBJECT?

    This is important, because the instance if it comes, as xml, you can use a tostring() to get a knot like a rope, archived documentation on the XML data on adobe livedocs

  • DataGrid and HttpService and XML

    Hello

    I get the following Http service XML. I'm fighting to display it in a Datagrid control. Help, please.
    < results >
    < result >
    < row >
    < cell name = "CLASS_GROUP" > cash and equivalents of < / cell >
    < cell name 'CLASS' = > Cash < / cell >
    < name of cell 'STYLE' = > Cash < / cell >
    < / row >
    < row >
    < cell name = "CLASS_GROUP" > cash and equivalents of < / cell >
    < cell name 'CLASS' = > Cash < / cell >
    < name of cell 'STYLE' = > Sweep funds < / cell >
    < / row >
    < row >
    < cell name = "CLASS_GROUP" > equity < / cell >
    < cell name 'CLASS' = > Asia Equity < / cell >
    < name of cell 'STYLE' = > Asia Pacific ex Japan Equity < / cell >
    < / row >
    < / result >
    < / results >

    The code to get the xml code is:

    < mx:HTTPService
    ID = "photoService".
    ' URL =' http://somehttpservice '
    resultFormat = "e4x".
    result = "photoResultHandler (Event); »
    Fault = "photoFaultHandler (Event); »
    / >
    < mx:XMLListCollection id = source="{photoService.lastResult.result.row}"/ "myXC" >

    Sorry I misread your message.

    Here's what you can do:







    and then, inside the extracted display function the value of xml. as:

    protected function displayClassGroup (subject: line, column: DataGridColumn): String {}
    var xmlObj:XMLList = row.cell;
    return xmlObj. (@name is "CLASS_GROUP");
    }

    Thank you
    Gaurav Jain
    Flex SDK Team

  • HTTPService and ResultEvent execution order

    Hello

    I have a function that I call to get data using a HTTPService, that has an eventlistener that calls another function to manage the data of the service receives.

    I wish I had my function that contains the function that returns a Boolean value based on whether the data has loaded the service. Something like:

            public function serviceFunction():Boolean 
            {
                ...
                service.addEventListener(ResultEvent.RESULT, dataFunction);
                ...
                service.send();
                return this.loaded;
                
            }          
    
            private function dataFunction(e:ResultEvent):void 
            {
                    if(e.result.data == loaded) {
                        this.loaded= true;                    
                    } else {
                        this.loaded= false;                    
                    }
    
                }
    

    When doing it this way, I find that the return statement is executed before the code within the function data.

    Is there a way to be able to return the Boolean value, updated in the first function?

    Thank you

    Alex.

    In short, no.. You're stuck with the asynchronous event in Flex. However, if you go out into the realm of JavaScript using the ExternalInterface, you can remove the synchronous data calls. However, there are not a lot of value to it. If you want to lock the State of your application while you wait for some kind of answer, just do this through the user interface.

  • HTTPService and XML

    Trying to pull back the XML of my twitter stream, but I can't seem to get the code to get the data. However if I run the httpservice url in the browser, it displays the xml file. It's just a proof of concept at the moment. Does anyone have any ideas? Thank you

    Managed to fix when I changed the resultFormat = "e4x" to "oppose" instead which then populate the datagrid control

  • HTTPService and CFC? Possible?

    I only see messages from CFM, but is possible to directly access a cfc of httpservice? Thank you

    I'll consider this resolved, the solution is to use cfm, but just have a var say what function to attend.

    i.e.
    var service: httpservice = new httpservice();
    service. BlahBlahBlah etc.
    var loginid:Object = new Object;
    LoginID.ID = '21';
    LoginID.Function = "3";
    service. Send (LoginID);

    then my cfm file is going to be pretty basic


    do I need the service.


    do I need the service.

    etc.

  • HTTPService request and the Actionscript questions

    Hello

    I don't know if anyone on the list could tell me what I'm trying to do here is possible. The scenario is that I have here a HTTPService which functionally works fine, but I want to do the rest of the processing in-house, instead of PHP (that of the HTTPService do the job)

    I wanted to make a function call to the HTTPService and then manage the variables I get from PHP, which currently I just use something like {simulation.lastResult.service.number}. If I want retrieve this value directly and do some manipulations of calculation with it in Actionscript, how can I retrieve the value of the above without having to rewrite my HTTPService? (Or, what is more effective?)

    Note: I am currently using PHP to do the same thing, but I would like to do in-house without hoarding my remote server.

    Any help is appreciated.

    Here's the HTTPService I:

    Try this example. It uses an XML file on my site that the data source and does not use PHP for any treatment, but it gives the basics.


    http://www.Adobe.com/2006/mxml '.
    layout = "absolute" >

    Import mx.controls.Alert;
    Import mx.rpc.events.FaultEvent;
    Import mx.rpc.events.ResultEvent;

    define your variables to the instance level and make sure that they are can be related
    [Bindable] private var totalBuy:int = 0;
    [Bindable] private var totalSell:int = 0;
    [Bindable] private var remaining: int = 0;

    private void resultHandler(e:ResultEvent): void {}
    This returns XML data your data may be different.
    You will see what the returned XML. Your code will change here
    According to what is returned.
    var xmlLst: XMLList = new XML (e.result) .children ();
    Alert.Show (xmlLst.toXMLString (), "Return Values");
    totalBuy = xmlLst [0];
    totalSell = xmlLst [1];
    remaining = totalBuy - totalSell;
    }

    private void faultHandler(e:FaultEvent): void {}
    Alert.Show (e.message.toString (), "Error");
    }
    private void runService(): void {}
    dataService.send ();
    }

    ]]>

    <>
    ID = "dataService."
    ' URL =' http://www.siteorderly.com/xml/costData.xml '
    resultFormat = "xml".
    result = "resultHandler (Event); »
    Fault = "FaultHandler (Event); » />







  • JavaScript JSON and ApEx integration

    In the community of ApEx, I see a lot of developers to extend their applications with JavaScript and JSON libraries. I would do the same thing to enjoy all the beautiful widgets, gadgets and gizmos that have been developed in the world of script.


    What is advice to better introduce the use of a script library?

    Team ApEx Oracle has an official thought on the extension of the ApEx in a script library?

    Y at - it a library which is recommended?

    Team ApEx does intend to extend their own library users don't need to use 3 parties?

    Have others using these issues experienced the 3rd-party libraries related to upgrades of the ApEx?


    I need a solution that is solid as a rock (no bugs) and bearable. The apps I support now have over a thousand users. Applications run on our company intranet. It would be undesirable to make calls outside our network http.

    Kind regards
    Todd

    Todd,

    We have certainly will continue work on the library, with the main objective on the realization of full namespace (to reduce the risk of collisions with different libraries functions) and the integration of jquery (making use of the features of the great library of basic such as chaining DOM selectors, improved, etc., but not of jquery UI).

    While it is currently possible to integrate with other libraries and many people have had great results with it, there are other plans for the future which should make life easier. To know custom item types, which allows developers to more easily code and reuse 3rd widgets to party in their applications.

    Another plan is what we call "Dynamic action", which will allow developers to set declaratively in the APEX for example activation, deactivation, display client side logic and hiding items. It is about making life easier for developers who do not want to dirty their hands with JavaScript, but still want to achieve such functionality in their applications.

    But I do not think that we could reach a point where "users have no need to use 3 parties. We are not all things to all people, different people have different requirements and tastes. For this reason, providing the best scalability (through custom item types) is the goal.

    We will also improve the documentation on the library, since 3.1, we had a few docs in chapter API user guide, but we will look to improve it with more detailed in future examples.

    Hope this helps,
    Anthony.

  • HTTPService to get hit emulator but not phone itself

    I develop an application that hits two HTTPServices - one after the other. My app works very well in the emulator, but success only deployed app the first HTTPService and does not seem to hit the 2nd one at all. I'm completely puzzled and if someone could help me, I would be eternally grateful. My code is below. Thanks in advance!

    < fx:Declarations >

    <! - Place non-visual elements (e.g., services, items of value) here - >

    < s:HTTPService id = " WebServiceNumber1 " resultFormat =" text " " "

    result = "ProcessOutputsOfWebServiceNumber1 (event)" showBusyCursor ="true""">

    http://domain.com/api/json?blah & sensor = false < s:url >< / s:url >

    < / s:HTTPService>

    "" < s:HTTPService id = "WebServiceNumber2" resultFormat = " text "result = "ProcessOutputsOfWebServiceNumber2 (event)" showBusyCursor = " true " " > "

    < s:url > http://domain.com/API/ASDF/JSON?blah & Sensor = false < / s:url >

    < / s:HTTPService>

    < / fx:Declarations >

    private function init():Sub

    {

    I want to hit the web service 2nd after the 1st to fill a

    WebServiceNumber1.addEventListener ('result', CallWebServiceNumber2);

    WebServiceNumber1.send (); / / No problem

    }

    private void ProcessOutputsOfWebServiceNumber1(event:ResultEvent):void

    {

    var strJSONResponse:String = String (event.result);

    things being done, everything works

    }                             

    private void CallWebServiceNumber2 (event: ResultEvent): void

    {

    WebServiceNumber2.send();//works in the emulator, not sure about phone

    lblTest.text = " WebServiceNumber2. send() pulled off..." » ;

    / / the above statement works, and the label gets changed

    }

    private void ProcessOutputsOfWebServiceNumber2(event:ResultEvent):void

    {

    var strJSONResponse:String = String (event.result); works in the emulator, not phone

    lblTest.text = strJSONResponse;                works in the emulator, phone no

    }

    Hello

    #1

    consider adding handlers for ResultEvent see if there is something wrong when executing

    #2

    You can take your second http service manager already set for the first service (do not know why you said two managers different just do the same job - but in different places). If your manager of "ProcessOutputsOfWebServiceNumber1" could be used to make the two functions (results management and update of second service) I think

    #3

    you could try to update params string by adding random id to check if what you are observing might be due to implementing caching on the device, see very easy implemented:

    [Bindable]

    private var randomID:int = 0;

    protected function udpateServiceHandler(event:MouseEvent):void

    {

    randomID = (new Date () .getTime ());

    WebServiceNumber2.send ();

    }

    http://www.domain.com/index.php?RID= {randomID}

    Before calling send() on webservice just update the random settings and that the change will be propagated through links.

    Kind regards

    Peter

  • Httpservice Adobe question

    Hello

    I have two questions about httpservice and combobox.

    1. I have a collection of array of objects of value, I want to send the data in these valuables on httpservices. My code for httpservice is:

    < mx:HTTPService

    id=" createAccount " url=" http://localhost/createAccount.php "method =" " POST "result ="accountResult (event)" >

    < mx:request xmlns = "" " >

    < username >

    < / username >

    < / mx:request >

    < / mx:HTTPService >

    If the data is directly from controls, this isn't a problem but if its a value object how to send data in the actionscripts?

    2. I want to know how to fill the ComboBox dynamically... for example, when I press a button, I want to fill the combobox with text comes from an edit box and I want to select this item. I checked the class combobox, additem funcion in there there no...

    Any help would be appreciated.

    Thank you

    Vahiny

    If this post answers your question or assistance, please mark it as such.

    (1) maybe just send the data using myVO.toString (), or else use JSON to encode the data. These links may help:

    http://www.switchonthecode.com/tutorials/Flex-PHP-tutorial-transmitting-data-using-JSON

    e http://www.switchonthecode.com/tutorials/using-Flex-php-and-JSON-to-Modify-a-MySQL-databas

    http://www.switchonthecode.com/tutorials/Flex-PHP-JSON-MySQL-Advanced-updating

    (2) adds the dataProvider of the ComboBox. With driver data controls, you almost always want to work on the dataProvider to influence on what appears in the control.


    http://www.Adobe.com/2006/mxml">
     
        Import mx.collections.ArrayCollection;
    [Bindable] private var ac:ArrayCollection = new ArrayCollection([)
    'one', 'two', 'three '.
    ]);
         
    private function clickFunc (): void {}
    If (txt.text! = "") {}
    ac.addItemAt (txt.text, 0);
    cbx.selectedIndex = 0;
    }
    }
    ]]>
     

     
     
     

Maybe you are looking for

  • Too many photos, full of SSD

    I can't seem to find the right solution here and I hope that some of you here can help out. My wife has a 512 GB SSD and is full (2.5 GB free). It has about 270 GB of photos, most are in Photos (iPhoto library import). I need to spend most of this on

  • HP probook, elitebook and zbook: GPU for rendering

    Hello!I plan to buy a new laptop that I will use also for Sony vegas pro. I wonder who this card (found in better HPs) would be better for the work:

  • HP monitor power button

    In some ways, the power button on my HP 20 "Monitor has been locked in position one.  This is a new computer with a chip AMD, 3 GB Ram, hard disk of 350, running Windows 7.

  • x 360 HDMI screen resolution

    Looking to buy a x 360 Pavilion to run mainly Office and Sibellius. Need to run with a larger screen. So if I connect a monitor (for example, HP Pavilion 22xi 54.6 cm (21.5 ") diagonal backlit LED IPS display) to using a HDMI Cable (the only way?) th

  • CD will not rip using Windows Media Player in windows 7

    I just had Windows 7 a few weeks ago and have had no problems until now to rip CD. However now it shows "windows media player is unable to extract one or more tracks from the cd. I went to TOOLS - OPTIONS - DEVICES - DRIVE, click on use a connection