Welcome, Guest
  • Author Topic: select combobox value from mysql result?  (Read 13592 times)

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #15 on: 09/29/08, 10:23 »
    Constructor of your DTO class that then looks like this:

    [as]
    package forms.orders
    {      
       
    [Bindable]
       public class orders extends Object
       {
          public var date:String;
          public var status:Number
          
          public function orders(obj:Object = null){
             if(currentOrder.date) date = currentOrder.date
             if(currentOrder.status) status= currentOrder.status   
          }
       }
    }
    [/as]

    Jorge

    jarmanje

    • Senior Programmer
    • ****
    • Posts: 334
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #16 on: 09/29/08, 12:44 »
    It seems i won't get off so lightly.

    Final error seems to be about my structure. but i have read about it and nothing is apparent


    Location   Creation Time   Id
    A file found in a source-path must have the same package structure 'forms', as the definition's package, 'forms.orders'.   adman2/src/forms   orders.as   

    jarmanje

    • Senior Programmer
    • ****
    • Posts: 334
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #17 on: 09/30/08, 17:56 »
    Can i just check, this code is 100% correct?
    It gives me this frustrating error:

    1172: Definition forms.Orders:orders could not be found.   adman2/src   main.mxml


    (inside folder 'forms') Orders.as
    Code: [Select]
    package forms.Orders
    {     
       
    [Bindable]
       public class orders extends Object
       {
          public var date:String;
          public var status:Number
         
          public function orders(obj:Object = null){
             if(currentOrder.date) date = currentOrder.date
             if(currentOrder.status) status= currentOrder.status   
          }
       }
    }


    inside <![CDATA[ of main.mxml
    Code: [Select]
    import forms.Orders.orders

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #18 on: 09/30/08, 21:19 »
    Should be inside forms/Orders/orders.as

    Jorge

    jarmanje

    • Senior Programmer
    • ****
    • Posts: 334
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #19 on: 10/01/08, 06:00 »
    I'm going to have to try with this other method and wait for your tutorial. I can't get past the errors.

    Now it won't let me call function          
    Code: [Select]
    import forms.Orders.Orders
    public var myOrder:orders = new orders({})

    I'm going to try to just catch the null value error:

    Code: [Select]
    <mx:DateField id = "orderdate" formatString="YYYY-MM-DD" width="170" showToday="true" text ="getDate()"/>


    private function getDate():String
    {
        if(currentOrder.orderid==0){
           
            return (new Date()).toString();
       
        } else {
        return currentOrder.date;
        }

    }

    The function does not get called at the moment. It will just say getDate() inside the text.
    « Last Edit: 10/01/08, 06:02 by jarmanje »

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #20 on: 10/01/08, 06:10 »
    Databinding works based on some property (like my example)

    text="{orderInfo.date}"

    You can supply current date in the logic of your DTO. or when fulfilling it, but not using a function as databinding

    Jorge

    jarmanje

    • Senior Programmer
    • ****
    • Posts: 334
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #21 on: 10/01/08, 06:57 »
    I really want to use your method but i can't

    if i use this way to define the var

    Code: [Select]
    public var myOrder:orders = new orders({});
    it gives me the error:

    1046: Type was not found or was not a compile-time constant: orders.   adman2/src/forms   OrderForm.mxml

    and if i use this way

    Code: [Select]
    public var myOrder:Orders = new orders({});
    i get the error:

    A file found in a source-path 'Orders' must have the same name as the class definition inside the file 'orders'.   adman2/src/forms/Orders   Orders.as


    i'm tantalizingly close


    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #22 on: 10/01/08, 07:28 »
    Basic task: import and instantiate a class
    The class should be in a path that reflects his package (com.flashdb.utils is com/flashdb/utils), and the name of the Class is the same as the as file, accesible from the source folder where you compile. External libraries path should be added rigth clicking in the Flex Project and editing the compiler path
    Work around this, is like ABC of programming

    Jorge

    jarmanje

    • Senior Programmer
    • ****
    • Posts: 334
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #23 on: 10/01/08, 11:25 »
    ok cool. followed the tutorial and got the class working.

    now trying to fix that the class cannot read the currentOrder var, says its undefined

    im going to try to replicate this

    http://nwebb.co.uk/nwebb_example_code/basic_architecture_example/srcview/index.html
    « Last Edit: 10/01/08, 12:04 by jarmanje »

    jarmanje

    • Senior Programmer
    • ****
    • Posts: 334
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #24 on: 10/01/08, 12:38 »
    Hows it possible for my class to access the Object in my mxml file?

    1120: Access of undefined property currentOrder.   adman2/src/classfolder   MyClass.as


    at this point, the values are fed into the currentOrder Object inside the file OrderForm.mxml. I cannot access it as usual with OrderForm.currentOrder




    jarmanje

    • Senior Programmer
    • ****
    • Posts: 334
      • View Profile
    Re: select combobox value from mysql result?
    « Reply #25 on: 10/06/08, 09:23 »
    As i couldnt get the classes to work properly, i'll wait for your tutorial to understand it better.

    I have a workaround code:
    Code: [Select]
    <mx:DateField id = "orderdate" formatString="YYYY-MM-DD" width="170" showToday="true" text = "{currentOrder.orderid==0 ? new Date().toDateString() : currentOrder.date}"/>

    I need the output to be "YYYY-MM-DD", but it is not as simple as Date().toDateString("YYYY-MM-DD")

    is there a way to work around this and achieve the custom format?