7 Replies Latest reply on Jun 15, 2010 6:31 AM by dhifallah

    how to show a list of order?

    dhifallah Level 1

      Hi,

       

      I'm working in a project in witch the user must choose some articles then he has to fill general information such as name, email... and then the summary of the order is showen with the defferent orders.

      all this work very good , but my problem is that the orders are showen in xml and I want to show them normal,

      I tried some thing witch show the order without xml  but when i try to command many articles, there is only the last article showen .

       

      var cartNode:XML = <Article/>;

      var items:ArrayCollection = cartData.items;

      var len:int = items.length;

       

      for (var i:int = 0; i < len; i++)

      {

      var Commande:XML = <Commande/>;

      cartNode.appendChild(Commande);

      Commande.@name= items[i].product.name;

      Commande.@quantity = items[i].quantity;

       

      }

       

      var userDetails:String = "Nom: " +cname.text + NL;

      userDetails += "Prénom: " + cname2.text + NL;

      userDetails += "Email: " + email.text + NL + NL + NL;

      userDetails += "Liste de la commande: " + NL + NL + Commande.@name + NL + NL + NL;

       

      var myAlert:Alert =Alert.show (userDetails," Récapitulatif de votre commande:");

       

      }

       

      Can you helpp me please

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

        • 1. Re: how to show a list of order?
          dhifallah Level 1

          Did you understand what I mean?

          • 2. Re: how to show a list of order?
            Dajji Level 3

            Can you provide proper code with xml structure? It's hard to understand your problem with the snippet you have shared.

            • 3. Re: how to show a list of order?
              BhaskerChari Level 4

              I din't understand exactly what you were trying to accomplish...Could you be a bit clear...?

               

               

              Thanks,

              Bhasker

              • 4. Re: how to show a list of order?
                dhifallah Level 1

                ok , sorry for my english , but I will try to be more clear.

                In my project the user have to choose articles to command them.after choosing he has to compleate the field of general information such as name, location of work,email...

                when finish there is a Summary of the order including the general information with the articles recommanded.

                for me all this work and i get all this informations inn the summary , but i get the articles with the a html code:

                I will show you the code , the the result.

                 

                 

                 

                var cartNode:XML = <Article/>;

                var  items:ArrayCollection = cartData.items;

                var len:int = items.length;

                 

                for (var i:int = 0; i < len; i++)

                {

                var  Commande:XML = <Commande/>;

                cartNode.appendChild(Commande);

                 

                Commande.@name= items[i].product.name;

                Commande.@quantity = items[i].quantity;

                }

                var userDetails:String = "Nom: " + cname.text + NL;

                userDetails += "Prénom: " + cname2.text + NL;

                userDetails += "Bureau: " + bureau.text + NL;

                userDetails += "Site: " + lieu.text + NL;

                userDetails += "Email: " + email.text + NL + NL + NL;

                userDetails += "Liste de la commande: " + NL + NL + cartNode.appendChild(Commande) + NL + NL + NL;

                 

                userDetails += "Commentaires du demandeur:"+ NL + NL + textCommentaire.text;

                 

                var myAlert:Alert =Alert.show (userDetails," Récapitulatif de votre commande:");

                myAlert.height = 400;

                myAlert.width = 500;

                }

                 

                 

                 

                 

                the following are the results showen in an Alert with OK button for sending them as an email

                 

                Nom: didi
                Prénom: doudou
                Bureau: B120
                Site: Vélizy
                Email: didi-doud@hotmail.fr


                Liste de la commande:

                <Article>
                  <Commande name="Post-It" quantity="1"/>
                  <Commande name="Pochette Transparante" quantity="1"/>
                  </Article>


                Commentaires du demandeur:

                blablabla

                 

                 

                 

                 

                So for me I don't whant to have these lines in html

                <Article>
                  <Commande name="Post-It" quantity="1"/>
                  <Commande name="Pochette Transparante" quantity="1"/>
                  </Article>

                 

                I want them normal , for exemple:

                Produit: Post-it       Quantité: 1

                 

                 

                I  tried the following code and get these results, but when i choose many articles theres is only the last article showen with the right quantity , I have to click on OK button to get the other Alert with other product. for me I want to see all product in the same Alert :

                 

                 

                 

                var items:ArrayCollection = cartData.items;

                 

                var len:int = items.length;

                 

                for (var i:int = 0; i < len; i++)

                {

                 

                var Commande:String;

                 

                var Quant:String;

                 

                 

                Commande= items[i].product.name;

                Quant= items[i].quantity;

                }

                 

                 

                var userDetails:String = "Nom: " + cname.text + NL;

                userDetails +=

                "Prénom: " + cname2.text + NL;

                userDetails +=

                "Bureau: " + bureau.text + NL;

                userDetails +=

                "Site: " + lieu.text + NL;

                userDetails +=

                "Email: " + email.text + NL + NL + NL;

                 

                userDetails +=

                "Liste de la commande: " + NL + NL + Commande + " "+"Quantité:"+Quant+ NL + NL + NL;

                userDetails +=

                "Commentaires du demandeur:"+ NL + NL + textCommentaire.text;

                 

                 

                var myAlert:Alert =Alert.show (userDetails," Récapitulatif de votre commande:");

                myAlert.height = 400;

                myAlert.width = 500;

                }

                 

                 

                • 5. Re: how to show a list of order?
                  Dajji Level 3

                  Okay...I have tried to understand your code and what you are trying to achieve.

                   

                  I believe you need an output like shown below.

                   

                   

                  Nom: didi
                  Prénom: doudou
                  Bureau: B120
                  Site: Vélizy
                  Email: didi-doud@hotmail.fr


                  Liste de la commande:

                   

                   

                  Produit: Post-it       Quantité: 1

                  Produit: Post-it       Quantité: 2

                  Produit: Post-it       Quantité: 5

                   

                  If that is the case the following line in your code will not help.

                   

                   

                  userDetails += "Liste de la commande: " + NL + NL + cartNode.appendChild(Commande) + NL + NL + NL;
                  

                   

                   

                  Instead, you can create a string at the top and populate that in your for loop. You can then concatenate that string in userDetails variable. Following is what I am suggesting here.

                   

                   

                  private var commands:String;
                  
                  
                  
                  
                  for (var i:int = 0; i < len; i++)
                  {
                  
                  
                  
                  
                  
                       var  Commande:XML = <Commande/>;
                       cartNode.appendChild(Commande);
                  
                       Commande.@name= items[i].product.name;
                       Commande.@quantity = items[i].quantity;
                  
                  
                       commands += "Produit:" + items[i].product.name;
                       commands += "Quantité:" + items[i].quantity;
                       commands += NL;
                       
                  }
                  
                  
                  
                  
                  
                  var userDetails:String = "Nom: " + cname.text + NL;
                  userDetails += "Prénom: " + cname2.text + NL;
                  
                  
                  userDetails += "Bureau: " + bureau.text + NL;
                  
                  
                  userDetails += "Site: " + lieu.text + NL;
                  
                  
                  userDetails += "Email: " + email.text + NL + NL + NL;
                  
                  
                  userDetails += "Liste de la commande: " + NL + NL + commands + NL + NL + NL;
                  
                  
                  
                  • 6. Re: how to show a list of order?
                    dhifallah Level 1

                    Thanks Dajji  for your reply. that's exactly what I want.

                    Now I want to send this summary byy email when the useer press OK Button. I created an HTTPService as the following:

                     

                     

                     

                    <mx:HTTPService id="HttpSendMail"

                    url="

                    http://localhost:8080/SupportWEBJ2EE/EmailServlet"

                    method="

                    GET" resultFormat="e4x"

                    useProxy="

                    false"

                    showBusyCursor="

                    true">

                         <mx:request xmlns="">

                     

                         <cname>{cname.text}</cname>

                     

                     

                         <cname2>{cname2.text}</cname2>

                     

                     

                         <bureau>{bureau.text}</bureau>

                     

                     

                         <lieu>{lieu.text}</lieu>

                     

                     

                         <email>{email.text}</email>

                     

                     

                         <textCommentaire>{textCommentaire.text}</textCommentaire>

                     

                     

                         <commands>{commands}</commands>

                     

                     

                     

                         </mx:request>

                     

                     

                    </mx:HTTPService>

                     

                    I receive the email with all the informations  but not commands, because here in my <mx:request >  tag I think that is not well declared.

                    In my servlet I get all  parameters like that:

                     

                    String cname = request.getParameter(

                    "cname");

                    String cname2 = request.getParameter(

                    "cname2");

                    String bureau = request.getParameter(

                    "bureau");

                    String lieu = request.getParameter(

                    "lieu");

                    String email = request.getParameter(

                    "email");

                    String textCommentaire = request.getParameter(

                    "textCommentaire");

                    String commands = request.getParameter(

                    "commands");

                     

                     

                    Then I put:

                     

                     

                    msg.setText(

                     

                    "Bonjour," +"\n\n"+

                     

                    "Merci de commander les fournitures suivantes à: "+"\n\n"+

                     

                    "Nom: "+cname+ "\n"+"Prénom: "+cname2+"\n"+"Bureau: "+bureau+"\n"+

                     

                    "Site: "+lieu+"\n"+"Email: "+email+"\n\n\n\n"+"Commentaires du demandeur:\n\n"+textCommentaire+"\n\n\n\n"+

                     

                    "Liste de la commande: " + "\n" + commands+

                     

                     

                     

                    But I get Null for Liste de la commande , in my email.

                     

                    Can you help me once again please

                    • 7. Re: how to show a list of order?
                      dhifallah Level 1

                      I resolved my problem .

                      I added

                      [

                      Bindable] private var commands:String;

                      Thank you all for your reply