11 Replies Latest reply on Sep 21, 2008 8:33 PM by

    Validation of  5 field - but only 3 field are displayed

      I´m trying to validate 5 fields. But when I´execute the .mxml file only 3 fields are displayed (shows up)

      Isn´t that weird?

      Please, can someone guide me of what´s the problem is.
      I should really appreciate if someone could do that.


      Here´s the cod:

        • 1. Re: Validation of  5 field - but only 3 field are displayed
          Peter Lorent Level 2
          If I run this in an Application tag, the 5 fields show. How are you running this?
          • 2. Re: Validation of  5 field - but only 3 field are displayed
            I am trying to build an Application with components
            called main.mxml with the component ValidationUsable2.mxml.
            An application that search a database in MySQL with Php and display
            the result through HTTPService in a datagrid in the main.mxml application.
            After the search the user can order the search result through a “form” build upon
            canvas component in the main.mxml.
            (I’m not using any form tags. Because they display an ugly layout/design)

            The problem is that I receive error message from the main.mxml like:
            -undefined property dgUserRequest

            And when I’m executing the ValidationUsable2.mxml I can’t see 5 fields.

            Therefore I can’t execute the Application so I can see the 5 fields from the component
            with canvas tags like you said.


            That’s very frustrating and I hope some nice person will guide me through this situation.


            Here’s the Application main.mxml.

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" width="1015" height="550" creationComplete="userRequest.send()" borderColor="#FFFFFF"
            backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]" xmlns:comp="components.*">
            <mx:Script>
            <![CDATA[
            // import mx.controls.Alert;
            import mx.rpc.events.ResultEvent

            ]]>
            </mx:Script>

            <mx:HTTPService id="userRequest" url=" http://localhost/case/script.php " useProxy="false" method="POST">
            <mx:request xmlns="">
            <artno>{artno.text}</artno>
            </mx:request>
            </mx:HTTPService>
            <mx:HBox width="100%" height="100%" y="0" x="0" styleName="colorPanel" borderStyle="solid">
            <mx:VBox width="230" height="100%">
            <mx:Canvas width="100%" height="100%">
            <mx:Canvas left="10" top="10" width="100%" height="60" backgroundColor="#ebebe9">
            <mx:Label left="10" top="10" text="SÖK I LAGRET" width="112" height="22" fontWeight="bold"/>
            <mx:Button left="168" top="30" label="Sök" width="47" height="20" click="userRequest.send()"/>
            <mx:TextInput left="10" top="30" height="20" width="150" id="artno"/>
            </mx:Canvas>
            <mx:Canvas left="10" top="78" width="100%" height="130" backgroundColor="#ebebe9">
            <mx:VBox left="10" top="10" width="100%" height="114" verticalGap="0">

            <mx:TextArea height="110" width="200" borderThickness="0" paddingLeft="2" paddingRight="2">
            <mx:text><![CDATA[Sök på tillverkarens nummer som exempelvis: FMA123456. När du gör en sökning så kan resultatet av din sökning visa ett annat tillverkningsnummer. Det beror på att det finns fler tillverkare av samma artikel. ]]></mx:text>
            </mx:TextArea>
            </mx:VBox>
            </mx:Canvas>
            <mx:Canvas x="10" y="78" height="460" width="220">
            <comp:ValidationUsable2 y="130" width="220" height="330" left="0"/>
            <mx:HRule x="0" y="130" width="220" strokeColor="#AAADAD"/>
            </mx:Canvas>
            </mx:Canvas>
            </mx:VBox>
            <mx:VBox width="750" height="100%">
            <mx:Canvas width="100%" height="100%" borderStyle="none">
            <!--Placeholder for logo-->
            <mx:Canvas id="mapCanvas" width="100%" height="35%" right="10" top="10">
            <mx:Image id="myImage" width="100%" scaleContent="false" height="100%" alpha="1.0" left="10" top="10" source="@Embed('/logo_head_final3.jpg')" horizontalCenter="0" verticalCenter="0"/>
            </mx:Canvas>
            <mx:Canvas width="100%" height="330" backgroundColor="#ffffff" borderStyle="solid" cornerRadius="0" bottom="10" right="10">
            <mx:Label left="10" top="2" text="RESULTAT AV SÖKNINGEN" width="173" height="15" fontWeight="bold"/>
            <mx:HBox left="0" top="43" width="100%" height="100%">
            <mx:Canvas width="100%" height="100%">

            <mx:DataGrid id="dgUserRequest" dataProvider="{userRequest.lastResult.titles.title}" horizontalCenter="-1" verticalCenter="2" height="100%" width="732" borderStyle="none">
            <mx:columns>
            <mx:DataGridColumn headerText="Tillverkarens nr" dataField="artno"/>
            <mx:DataGridColumn headerText="Benämning" dataField="benamning"/>
            <mx:DataGridColumn headerText="Anm" dataField="anm"/>
            <mx:DataGridColumn headerText="Pris/st" dataField="pris"/>
            <mx:DataGridColumn headerText="Antal i lager" dataField="antal"/>
            </mx:columns>
            </mx:DataGrid>


            </mx:Canvas>

            </mx:HBox>

            </mx:Canvas>

            </mx:Canvas>

            </mx:VBox>

            </mx:HBox>

            </mx:Application>
            <mx:Canvas x="10" y="78" height="460" width="220">
            <comp:ValidationUsable2 y="130" width="220" height="330" left="0"/>
            <mx:HRule x="0" y="130" width="220" strokeColor="#AAADAD"/>
            </mx:Canvas>

            • 3. Validation of  5 field - but only 3 field are displayed
              Peter Lorent Level 2
              Do you have this script running on a server too so I can run the app?
              http://localhost/case/script.php
              1 person found this helpful
              • 4. Re: Validation of  5 field - but only 3 field are displayed
                Peter Lorent Level 2
                <mx:Canvas x="10" y="78" height="460" width="220">
                <comp:ValidationUsable2 y="130" width="220" height="330" left="0"/>
                <mx:HRule x="0" y="130" width="220" strokeColor="#AAADAD"/>
                </mx:Canvas>

                What is that doing at the bottom of the main.mxml? Is doesn't belong there and will generate an error. Remove that and the main.mxml will run.
                1 person found this helpful
                • 5. Re: Validation of  5 field - but only 3 field are displayed
                  <mx:Canvas x="10" y="78" height="460" width="220">
                  <comp:ValidationUsable2 y="130" width="220" height="330" left="0"/>
                  <mx:HRule x="0" y="130" width="220" strokeColor="#AAADAD"/>
                  </mx:Canvas>

                  <What is that doing at the bottom of the main.mxml? Is doesn't belong there and will generate an error. Remove <that and the main.mxml will run.


                  I´m not sure if you really understand how you can build a custom component in Flex.
                  Maybe I was unclear in my last post?

                  Each Flex application can be broken into multiple mxml files which are custom classes
                  and I do not want one monolithic file.


                  Custom components:
                  The best practice is to break up into a large mxml-file into multiple mxml files.
                  I’ve done that.
                  Because It´s more flexible and easier to manage smaller pieces rather the a large mxml-file.
                  And you can reuse this smaller pieces in another parts of the application

                  If I remove the code as you suggest.
                  How do I then separate the application into multiple custom mxml components??
                  And most of all how do I display the 5 fields In the main.mxml??

                  So my question is still the same as in my last post.

                  • 6. Re: Validation of  5 field - but only 3 field are displayed
                    Peter Lorent Level 2
                    Hmm, I think I know a few things of building custom components, mainly because I do this regularly but hey, maybe I've been doing it the wrong way for years now. That would be something...

                    <comp:ValidationUsable2 y="130" width="220" height="330" left="0"/>

                    With that line (and by adding the namespace xmlns:comp="components.*") you use the custom component, not by adding it at the bottom of the main.mxml.
                    Just consider that mxml is in fact xml. Which means you simply have invalid xml because there is no root in your main.mxml file.

                    The code runs once you remove the bottom part, like I said, and when I run it, I see the 5 fields. Only thing that remains are a wrong reference to the submit button and the reference to the datagrid in the main.mxml in the component.
                    1 person found this helpful
                    • 7. Validation of  5 field - but only 3 field are displayed
                      <With that line (and by adding the namespace xmlns:comp="components.*")
                      <you use the custom component, not
                      <by adding it at the bottom of the main.mxml.
                      <Just consider that mxml is in fact xml. Which means you simply have invalid xml
                      <because there is no root in your
                      <main.mxml file.

                      I´m sorry, that part is not at the end - it´s within the start and end tags in the main.mxml.(See the code below)
                      I dont really know why the code did show up there when I wrote the post.
                      Cut and paste did some mess in that post.



                      <The code runs once you remove the bottom part, like I said, and when I run it,
                      <I see the 5 fields. Only thing that
                      <The code runs once you remove the bottom part

                      How can you see these fields if you remove the path to the component in the main.mxml???
                      - Or which part do you refer to in the code?
                      - I´m talking about the 5 validation fields in thhe reusable component
                      ValidationUsable2.mxml which not are displayed in main.xml when I remove the code as you suggest.


                      Here´s the part of that code in the main.mxml within the application tags;

                      <?xml version="1.0" encoding="utf-8"?>
                      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" width="1015" height="550" creationComplete="userRequest.send()" borderColor="#FFFFFF"
                      backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]" xmlns:comp="components.*">
                      <mx:Canvas x="10" y="78" height="460" width="220">
                      <comp:ValidationUsable2 y="130" width="220" height="330" left="0"/>
                      <mx:HRule x="0" y="130" width="220" strokeColor="#AAADAD"/>
                      </mx:Canvas>
                      ..
                      </mx:Application>



                      <remains are a wrong reference to the submit
                      <button and the reference to the datagrid in the main.mxml in the
                      <component.

                      Yes, I know that - and I´m really appreciate some ansver on that.
                      Please, dont give up, even if was unclear in my first post
                      - I do really appreciate your help!
                      • 8. Validation of  5 field - but only 3 field are displayed
                        Peter Lorent Level 2
                        Maybe it's best if I post the app so we can see what the problem is. I've posted the app and source view is enabled so you can download a zip with the code.

                        In the code I've resolved the reference to the datagrid:
                        I've added a public var to the component (better use a setter here...) and set the reference:
                        <comp:ValidationUsable2 y="130" width="220" height="330" left="0" dGrid="{dgUserRequest}"/>
                        (you can consider mxml files as being classes)

                        Well, have a look at the app and let me know if this is what you want to show, view wise...
                        • 9. Re: Validation of  5 field - but only 3 field are displayed
                          Please try this instead:
                          This is gonna clear a lot for you - here´s the source code:
                          main.mxml:
                          http://www.goodwill.se//powerparts/php/uploads.rar
                          As you can see I have done 2 major modification
                          //Try to solve the scope problem
                          1. import mx.core.Application.application
                          2. Target the datagrid

                          I hope everything are much more clear now.

                          • 10. Re: Validation of  5 field - but only 3 field are displayed
                            Peter Lorent Level 2
                            If you want to use the reference to the Application you need to change your import statement to:
                            import mx.core.Application;

                            • 11. Validation of  5 field - but only 3 field are displayed
                              <If you want to use the reference to the
                              <Application you need to change your import statement to:
                              <import mx.core.Application;

                              Thanks a lot