5 Replies Latest reply on Nov 17, 2008 8:41 AM by Karl_Sigiscar_1971

    RemoteClass use limitations ?

    fxBR
      Hello,
      I'm a Flex newbie, but I already have some classes "mirroring" my Java classes that comes from BlazeDS.
      My problem is ... I have a parent class Payment, and three subclasses SUBClassPaymentA, SUBClassPaymentB, SUBClassPaymentC. SUBClassPaymentA and SUBClassPaymentB are working fine, but SUBClassPaymentC does not get bound, it binds to a generic object. I tested the function result in Java and all three subclasses come OK, with the inherited field and everything ...

      The only difference between SUBClassC and the other ones, is that the first one carries another remote class inside of it. But, when I look at the class C that came from the server and was cast to a generic object in the debugger, that inner class gets cast OK. I was assuming that there were a limitation for the RemoteClass tag, but I don't know, because all three class are declared the exactly same way ...

      If you need some code, pls let me know ...

      Thanks in advance,
        • 1. Re: RemoteClass use limitations ?
          fxBR Level 1
          Hi,

          Just a note .. It is fixed already ... I don't understand why, but I was trying, on the Result function, to a loop in the ArrayCollection to try to look for a specific property and cast manually, but before that, I just declared a variable with the SUBPaymentClassC to hold the future cast object and it worked ...

          Totally crazy, I know ... just declaring a variable ... not assigning anything to it ... Maybe a bug ... I don't know ...

          But it is working ...

          Thanks,
          • 2. Re: RemoteClass use limitations ?
            Peter Lorent Level 2
            Search this forum for 'inheritance'. I remember a post by awaterma on this issue.
            • 3. Re: RemoteClass use limitations ?
              Level 7

              "fxBR" <webforumsuser@macromedia.com> wrote in message
              news:gfpt28$o92$1@forums.macromedia.com...
              > Hi,
              >
              > Just a note .. It is fixed already ... I don't understand why, but I was
              > trying, on the Result function, to a loop in the ArrayCollection to try to
              > look
              > for a specific property and cast manually, but before that, I just
              > declared a
              > variable with the SUBPaymentClassC to hold the future cast object and it
              > worked
              > ...
              >
              > Totally crazy, I know ... just declaring a variable ... not assigning
              > anything
              > to it ... Maybe a bug ... I don't know ...

              http://flexdiary.blogspot.com/2008/11/thoughts-on-remoting.html

              second to last paragraph


              • 4. Re: RemoteClass use limitations ?
                John Hall Level 4
                Amy is right on. It's a bit counterintuitive but if there is no instantiation of the client side variable (despite having mapped the relationship between the remote and local classes) the client-side class apparently doesn't get exported so it can't be referenced. Just creating a dummy variable within Flex that instantiates the class does the trick. This is a hard one to catch if you haven't fun into it before.
                • 5. Re: RemoteClass use limitations ?
                  Karl_Sigiscar_1971 Level 3

                  Yes, the LCDS documentation says that you have to explicitly cast the result to the mapped Java entity.

                  You do not necessarily need to declare a variable.

                  Quoting Adobe:

                  In the ActionScript class, you use the [RemoteClass(alias=" ")] metadata tag to create an ActionScript object
                  that maps directly to the Java object. The ActionScript class to which data is converted must be used or referenced
                  in the MXML file for it to be linked into the SWF file and available at run time. A good way to do this is by casting
                  the result object, as the following example shows:
                  var result:MyClass = MyClass(event.result);
                  The class itself should use strongly typed references so that its dependencies are also linked.