4 Replies Latest reply on Aug 30, 2006 3:15 AM by Newsgroup_User

    Java adapter example not compiling

    smakwam2006
      Hi folks,
      Can anyone please let me know why I get the error : "1046: Type was not found or was not a compile-time constant: Contact"
      on this line : public var contact:Contact; in my Flex 2 app example which I am following at http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=L iveDocs_Parts&file=00000138.html

      I have followed the tut so far down to the letter, but still no joy.
      I have the following setup:
      1) flex 2 data services setup at :
      2) copied the structure as required for Contact.as - this file is in the folder C:\fds2\jrun4\servers\default\samples\DSLessons\samples\contact\Contact.as which as far as I can tell is correct. The contents of contact.as is straight from Adobe :
      ////////////////////////////////////////////////////////////////////////////////
      //
      // Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
      // All Rights Reserved.
      // The following is Sample Code and is subject to all restrictions on such code
      // as contained in the End User License Agreement accompanying this product.
      // If you have received this file from a source other than Adobe,
      // then your use, modification, or distribution of it requires
      // the prior written permission of Adobe.
      //
      ////////////////////////////////////////////////////////////////////////////////
      package samples.contact
      {

      [Managed]
      [RemoteClass(alias="samples.contact.Contact")]
      public class Contact
      {
      public var contactId:int;

      public var firstName:String = "";

      public var lastName:String = "";

      public var address:String = "";

      public var city:String = "";

      public var state:String = "";

      public var zip:String = "";

      public var phone:String = "";
      }
      }



      !!
      the mxml is :


      <?xml version="1.0" ?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Script>
      <![CDATA[
      import mx.data.DataService;
      import mx.collections.ArrayCollection;
      import samples.contact.Contact;

      public var ds:DataService;

      [Bindable]
      public var contacts:ArrayCollection;
      public var contact:Contact;

      ]]>
      </mx:Script>


      <mx:DataGrid id="dg" editable="true">
      <mx:columns>
      <mx:DataGridColumn dataField="contactId" headerText="Id" editable="false"/>
      <mx:DataGridColumn dataField="firstName" headerText="First Name"/>
      <mx:DataGridColumn dataField="lastName" headerText="Last Name"/>
      </mx:columns>
      </mx:DataGrid>



      </mx:Application>

      as you can see, I have not even completed it yet !!!!


      any help would be appreciated.



      Thanks
      Smak
        • 1. Re: Java adapter example not compiling
          Jorge_Juan Level 1
          In which directory is your mxml file? It should be in C:\fds2\jrun4\servers\default\samples\DSLessons.
          The import samples.contact.Contact tells the compiler to look for a directory structure samples\contact, then the class Contact.as. This dir structure has to be under relative to the mxml file.

          -Jorge
          • 2. Re: Java adapter example not compiling
            Jorge_Juan Level 1
            BTW, a note was added by the Adobe doc guys:
            mpeterson said on Jul 5, 2006 at 1:19 PM :

            The "contact" sample application used in this tutorial IS NOT included in the Flex Data Services samples web application. The required files are available in the following zip file, which you can unzip into the samples (root directory) of the samples web application:
            http://www.adobe.com/go/flex2_contact_app_zip

            After unzipping the file, copy the following destination definition after the last destination in the samples/WEB-INF/flex/data-management-config.xml file:
            <destination id="contact">

            <adapter ref="java-dao" />

            <properties>
            <source>samples.contact.ContactAssembler</source>
            <scope>application</scope>

            <metadata>
            <identity property="contactId"/>
            </metadata>

            <network>
            <session-timeout>20</session-timeout>
            <paging enabled="false" pageSize="10" />
            <throttle-inbound policy="ERROR" max-frequency="500"/>
            <throttle-outbound policy="REPLACE" max-frequency="500"/>
            </network>

            <server>
            <fill-method>
            <name>loadContacts</name>
            </fill-method>

            <fill-method>
            <name>loadContacts</name>
            <params>java.lang.String</params>
            </fill-method>

            <sync-method>
            <name>syncContacts</name>
            </sync-method>
            </server>
            </properties>
            </destination>

            - Mike Peterson
            Adobe Flex documentation team

            • 3. Re: Java adapter example not compiling
              smakwam2006 Level 1
              Jorge,
              thanks for the quick reply, it is ok now I think.

              Regards
              Smak
              • 4. Re: Java adapter example not compiling
                Level 7
                Jorge,
                thanks for the quick reply, it is ok now I think.

                Regards
                Smak