开发者

Flex java problem!

my problem is that: I have a java class like this,

     public class DogrusalTekliHareket {


        public Degiskenler Son; 

        public void Bul()
        { 
          //.... 
         }
 }

When ı try to use something like that,

  <fx:Script>
  <![CDATA[

    var hesaplama:DogrusalTe开发者_C百科kliHareket= new DogrusalTekliHareket();
    hesaplama.Son;

]]>
</fx:Script>

it give error with using hesaplama.Son. What is the problem and how can ı use Son ?


The problem is that accessing hesaplama.Son is not doing anything and not a valid expression.

Try:

var hesaplama:DogrusalTekliHareket= new DogrusalTekliHareket();
var hesaplamaSon:Degiskenler  = hesaplama.Son;


BlazeDS requires that when you deserialize and serialize objects, you do it through getters and setters. Make sure your Java class has getters and setters for instance variables.


Ok. You should have at least two different and rather unrelated projects: one with server side Java code (I suppose it should be WTP Dynamic Web Project) and another is a Flex or ActionScript project with MXML/ActionScript code. WTP and Flash Builder allow to configure project settings to have both Flex and Java projects in a single WTP/Flex project but anyway they just have common output folders but have different project natures and build separately with different compilers.

This way Flex and Java code are unrelated. They haven't common Java/ActionScript/MXML/jar/swc dependencies and you can't use Java code in Flex part and vice versa.

So to use some DTO on a server (I mean Java) side you should declare this DTO in Java. And to have some DTO on a client side you should declare it in ActionScript. And client-server interaction will be performed via HTTP using AMF (in case of BlazeDS) serialization which is rather language independent. But it can be XML or JSON which are language independent too.

To make client/server synchronization easier you can use some code generators which can generate both Java and ActionScript sources from the single declarations. I mean something like Clear Toolkit (and ClearDataBuilder in particular) or Spring Roo (with Spring/BlazeDS integration). But anyway they generate separate Java and ActionScript/MXML sources which can be compiled separately (using javac and mxmlc respectively).

Hope this helps!

P.S. And sorry for my little remark about your naming standards. I suppose it is a little easier for you to have identifiers in Turkish (as far as it is a little easier for me to have Russian identifiers) but all the modern computer languages are in English and all the international communities, like, for example, StackOverflow, are in English. And it will better for you and for potential supporters of your code to accustom yourself to use English identifiers.


I know we're doing this sort of thing all the time in the Flex apps I've worked on, but one thing I notice we do that you don't seem to be is that we actually create our own ActionScript object analog for the Java object, then use the RemoteClass annotation in ActionScript to inform the engine that "this" ActionScript class should be used for "that" Java class. Also, you define the getters and setters on the Java side, on the Flex/ActionScript side it will come up as hesaplama.son, if follows basically the same naming conventions that JSP EL does for transforming property names.

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜