Welcome, Guest
  • Author Topic: Accessing returned objects  (Read 2932 times)

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Accessing returned objects
    « on: 07/25/10, 06:30 »
    I have a little project, displaying and processing data from a webshop.

    I got stuck, because I oversee something. As more I look, the less I see ;)

    If have this declaration:
    Code: [Select]
    <productsservice:ProductsService id="productsService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
    <s:CallResponder id="userLoginResult" fault="Alert.show('Anmeldung ist fehlgeschlagen','Systemmeldung')" result="login_result(userLoginResult)"/>
    <s:CallResponder id="articleSearchResult" fault="Alert.show('Abfrage ist fehlgeschlagen\n'+event.fault.faultDetail,'Fehlermeldung')" result="listResult(articleSearchResult)" />
    <s:CallResponder id="getProductDetailsResult" fault="Alert.show('Abfrage ist fehlgeschlagen\n'+event.fault.faultDetail,'Fehlermeldung')" result="displayProduct(getProductDetailsResult)"/>

    the first two work perfectly as expected.
    But the displayProduct function is never called.

    If I watch this in Charles, data is received as expected, but never displayed.
    The debugger does not want to communicate, which does not make it easyer.

    Code: [Select]
    getProductDetailsResult.lastResult.data.products_ean
    this passes the compiler ok, but never receives any data, even though the data is there (as Charles says).
    happy flashing
    8)
    Ronald

    papachan

    • Systems Administrator
    • *****
    • Posts: 507
      • View Profile
      • Air Flex Developer
    Re: Accessing returned objects
    « Reply #1 on: 07/26/10, 08:09 »
    when the things gone to fast, i generally use a setTimeOut function, it generally help the flash player in some cases.

    kofi addaquay

    • Global Moderator
    • Senior Programmer
    • *****
    • Posts: 450
      • View Profile
      • Scripton Interactive
      • Email
    Re: Accessing returned objects
    « Reply #2 on: 07/26/10, 17:11 »
    very weird indeed !

    did you get this solved? what does your displayProduct function look like?

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Accessing returned objects
    « Reply #3 on: 07/27/10, 02:44 »
    I striped the function down to only show a message box.
    It is not even called.

    Accessing the lastResult ends in empty values, even though I see the values in Charles exactly as expected.
    Code: [Select]
    protected function displayProduct(p:CallResponder):void{
    //Alert.show(p.lastResult.data.products_price,"Preisinfo");
    //this.productDetail=p.lastResult.data;
    //Alert.show(this.productDetail.products_name,"Debuginfo");
    Alert.show("Daten empfangen","Debug");
    }

    and the result screen of Charles delivers:
    Code: [Select]
    body Object
    data Object
    err Integer 0
    msg String 1 Datensätze gefunden.
    Data opened:
    Code: [Select]
    products_id String 3334
    products_ean String 8436032420035
    products_quantity String 9
    products_shippingtime String 1
    products_model String OCC-13600
    ...
    happy flashing
    8)
    Ronald

    kofi addaquay

    • Global Moderator
    • Senior Programmer
    • *****
    • Posts: 450
      • View Profile
      • Scripton Interactive
      • Email
    Re: Accessing returned objects
    « Reply #4 on: 07/27/10, 10:07 »
    still hard to see :D

    where are you calling your send()?

    are you using httpservice anywhere?

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Accessing returned objects
    « Reply #5 on: 07/27/10, 10:27 »
    It is called, when you click into a datagrid:

    <mx:DataGrid id="productList" x="10" y="173" width="555" height="284" editable="false" click="getProductDetails(productList.selectedItem.products_id)">

    Code: [Select]
    protected function getProductDetails(pid:int):void{
    Alert.show("Nach Artikel "+pid+" wird gesucht","Info");
    getProductDetailsResult.token = productsService.getProductDetails(pid);
    selector.selectedItem=productDetails;
    }

    This function is definately called, because the selector (its a tabbed controll) changes, and as I mentioned, Charles does deliver the expected data.
    « Last Edit: 07/27/10, 10:28 by Ronald Wernecke »
    happy flashing
    8)
    Ronald

    kofi addaquay

    • Global Moderator
    • Senior Programmer
    • *****
    • Posts: 450
      • View Profile
      • Scripton Interactive
      • Email
    Re: Accessing returned objects
    « Reply #6 on: 07/27/10, 10:55 »
    yes its being called one way...and not returning..

    not sure...the first thing that comes to mind is your result handler function displayProduct..because that is what gets fired when data comes to flex

    the function taking a parameter p of type CallResponder (p:CallResponder). i think this is wrong:) it should be ResultEvent. did you try that?

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Accessing returned objects
    « Reply #7 on: 07/27/10, 11:50 »
    I tried this - it definately delivers a object of the type mx.rpc:CallResponder

    Error message says - cannot convert CallResponder to incompatible ResultEvent

    And the other services work, which are written the same way.

    The call itself works - I can see the result in Charles
    happy flashing
    8)
    Ronald

    kofi addaquay

    • Global Moderator
    • Senior Programmer
    • *****
    • Posts: 450
      • View Profile
      • Scripton Interactive
      • Email
    Re: Accessing returned objects
    « Reply #8 on: 07/27/10, 11:59 »
    Hmm... have you tried skipping mxml entirely for that one service and using actionscript instead?

    have you used the ItemResponder and AsynToken method to try and solve this problem?

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Accessing returned objects
    « Reply #9 on: 07/27/10, 13:59 »
    Nope - i have hoped, you can see a typo, i didnt find ;)
    I can't think of anything else, because the other routines are working perfectly.

    But I think, I have to reinstall Flex, to make the debugger running.
    This is the last chance to find the bug.

    Sure, it might be even better to encapsulate the service calls in a AS-Class.
    happy flashing
    8)
    Ronald

    kofi addaquay

    • Global Moderator
    • Senior Programmer
    • *****
    • Posts: 450
      • View Profile
      • Scripton Interactive
      • Email
    Re: Accessing returned objects
    « Reply #10 on: 07/27/10, 14:04 »
    yes i hate it when things like that happen

    you know very well that it should work...but it doesnt. >:( try the actionscript way. if it doesnt work... you can try your reinstall. let me know if you need help in the ItemResponder and AsynToken way of doing it. But you should be able to do it easy !

    Kofi

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Accessing returned objects
    « Reply #11 on: 08/01/10, 15:39 »
    you are right - I got lost in all these new classes ;)
    It looks, like they over complicated some simple things.
    I got to get deeper into these classes.
    Most examples use combinations of MXML and AS, which seam to make trouble in my case.
    happy flashing
    8)
    Ronald