12 Replies Latest reply on Aug 26, 2010 8:35 AM by flexillu10

    What can i use Data/Services for?

    flexillu10 Level 1

      I have a datagrid displaying data from my database and i can get access to whichever data item i want.

       

      What i want to do is use data from the database without creating a data grid, how can i do that?

       

      e.g displaying a text field from the database in a textbox, how would i do this without calling datagrid.selecteditem...?

        • 1. Re: What can i use Data/Services for?
          Balakrishnan V Level 3

          You can store the results of a service invocation as an arraycollection of records and access items from within the arraycollection.

           

          Does this answer your query ?

           

          Balakrishnan V

          • 2. Re: What can i use Data/Services for?
            flexillu10 Level 1

            Balakrishnan V wrote:

             

            You can store the results of a service invocation as an arraycollection of records and access items from within the arraycollection.

             

            Does this answer your query ?

             

            Balakrishnan V

             

            Yes this is what i was looking for, could you give me some example code? And where would i put this code? in the first windowed application tag?

            • 3. Re: What can i use Data/Services for?
              Prestine

              Hello,

               

              You can create a Singleton Class and declare one variable in this class, which will contain/hold the results of a service invocation.

               

              You can use this variable whereever  you want in the whole Application.

               

              Regards,

              • 4. Re: What can i use Data/Services for?
                flexillu10 Level 1

                Prestine wrote:

                 

                Hello,

                 

                You can create a Singleton Class and declare one variable in this class, which will contain/hold the results of a service invocation.

                 

                You can use this variable whereever  you want in the whole Application.

                 

                Regards,

                what type of variable? an array? or arrayCollection? can you give me some example code

                • 5. Re: What can i use Data/Services for?
                  Balakrishnan V Level 3

                  <?xml version="1.0" encoding="utf-8"?>

                  <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                     xmlns:s="library://ns.adobe.com/flex/spark"

                     xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="windowedapplication1_creationCompleteHandler(event)">

                  <fx:Script>

                  <![CDATA[

                  import mx.collections.ArrayCollection;

                  import mx.events.FlexEvent;

                  import mx.rpc.events.ResultEvent;

                   

                  [Bindable] private var resultData:ArrayCollection=new ArrayCollection()

                   

                  protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void

                  {

                  // TODO Auto-generated method stub

                  myHTTPService.send()

                  }

                  protected function myHTTPService_resultHandler(event:ResultEvent):void

                  {

                  // TODO Auto-generated method stub

                  resultData=event.result as ArrayCollection;

                  // resultData=myHTTPService.lastResult as ArrayCollection

                  }

                  ]]>

                  </fx:Script>

                  <fx:Declarations>

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

                  <s:HTTPService id="myHTTPService" result="myHTTPService_resultHandler(event)"

                     url=""/>

                  </fx:Declarations>

                  </s:WindowedApplication>

                  Hope this helps,
                  Balakrishnan V

                  • 6. Re: What can i use Data/Services for?
                    Balakrishnan V Level 3

                    And .. why should there be a singleton class and not a simple ArrayCollection ?

                    • 7. Re: What can i use Data/Services for?
                      flexillu10 Level 1

                      ok thanks a lot that does help. But can i just check

                       

                      My applicaiton needs to be as follows

                       

                      i have images stored at a http web address, i have a database storing the url's of the images. I want my air app to go to to the url, grab the image and open it with windows picture and fax viewer.

                       

                      I have acheived this so far using a datagrid, i used flash builder data connect wizard to connect to the database, and it generated some services. I used the get all service and dragged it onto a datagrid. I then used whichever field i needed and was successful. However now i want to display the jpegs as clickable images so the user can click the image to open it instead of selecting one from the data grid.

                       

                      Therefore i jsut need this get all service stored as an array collection don't i?

                       

                      So thanks for the code, but it seems to use a http service, which i'm now not sure if i need

                      • 8. Re: What can i use Data/Services for?
                        Prestine Level 1

                        Depends, what kind of data is coming from the service side

                        • 9. Re: What can i use Data/Services for?
                          Prestine Level 1

                          If It is used in a single class/component then arraycollection is ok.

                           

                          but if the arraycollection will be used in different components , then arraycollection has to be stored in Singleton Class and used whereever required...... right or wrong?

                           

                           

                          Thanks and Regards,

                          • 10. Re: What can i use Data/Services for?
                            flexillu10 Level 1

                            the data coming in will be text strings, i just want to use the text fields,

                             

                            My question is:

                             

                            how do i bind the service to an array or something else instead of binding it to a datagrid?

                            • 11. Re: What can i use Data/Services for?
                              Prestine Level 1

                              [Bindable]

                              private var str:String;

                               

                              in the result method, you will use this code, to get the value return from the service end.

                               

                                                        str   = event.result as String;

                               

                               

                               

                              Use  str where ever you want.

                               

                               

                               

                              Regards,

                              • 12. Re: What can i use Data/Services for?
                                flexillu10 Level 1

                                Hello,

                                 

                                Sorry but i have no idea how to generate a result handler for a service that i don't know how to call.

                                 

                                Before i just dragged the php service onto a datagrid, i just want to do the same but store it in an array, Please can you give me an "idiot's guide" for how i would do this