problem in binding xml file data to datagrid xml file isgenerated through JSP file

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default problem in binding xml file data to datagrid xml file isgenerated through JSP file

    problem it that i am creating xml file using JSP file and i want to bind
    DataGrid with xml file data that is created using JSP
    but it will not Bind

    two basic err occcur jsp file when i compiling MXML file

    1) <xml> the xml tag only appear as first text in the file
    2) problem parsing external xml

    i need proper solution both file code are as under
    *******************************JSP
    file********************************************** **

    <%@ page contentType="text/html; charset=iso-8859-1" language="java"
    import="java.sql.*" errorPage="" %>
    <?xml version="1.0" encoding="iso-8859-1"?>
    <employees>
    <%
    Connection conn=null;
    try
    {
    String driverName="org.gjt.mm.mysql.Driver";
    Class.forName(driverName);

    String url="jdbc:mysql://192.168.1.149/flextest";
    String username="root";
    String password="vamsi";
    conn=DriverManager.getConnection(url,username,pass word);
    out.println("Connection...");
    String query="Select * from temp";
    Statement stmt=conn.createStatement();
    ResultSet rs=stmt.executeQuery(query);
    while(rs.next())
    {
    %>
    <employee>
    <id> <% out.println(rs.getString(1)); %> </id>
    <phone> <% out.println(rs.getString(2)); %> </phone>
    <email> <% out.println(rs.getString(3)); %> </email>
    </employee>

    <%
    }

    }
    catch (ClassNotFoundException cle)
    {
    System.out.println("ClassNotFoudException :"+cle);
    } catch (SQLException e)
    {
    System.out.println("ClassNotFoudException :"+e);
    // Could not connect to the database
    }
    %>
    </employees>


    *********************************************MXMLF ILE***************************
    **********************************
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">

    <mx:HTTPService id="employeeSrv" useProxy="false" method="POST"
    url="http://localhost:8888/samples/chinmay/emp.jsp" >
    <mx:request>
    <id>{name.text}</id>
    <phone>{phone.text}</phone>
    <email>{email.text}</email>
    </mx:request>
    </mx:HTTPService>

    <mx:Script>
    function addRow() {
    if (name.text != "") dg.addItem( {id: name.text, email:
    email.text, phone: phone.text} );
    employeeSrv.send();

    }

    function updateRow() {
    if (dg.selectedIndex!=undefined)
    dg.replaceItemAt(dg.selectedIndex, {id: name.text, email:
    email.text, phone: phone.text} );
    }

    function deleteRow() {
    if (dg.selectedIndex!=undefined) {
    dg.removeItemAt(dg.selectedIndex);
    name.text=""; email.text=""; phone.text="";
    }
    }
    </mx:Script>
    <mx:Model id="empdata"
    source="http://localhost:8888/samples/chinmay/emp.jsp"/>
    <mx:Panel xmlns:mx="http://www.macromedia.com/2003/mxml" width="400"
    height="419">
    <mx:VBox>
    <mx:DataGrid id="dg" dataProvider="{empdata.employee}">
    <mx:columns>
    <mx:Array>
    <mx:DataGridColumn headerText="id" columnName="id" />
    <mx:DataGridColumn headerText="phone" columnName="phone" />
    <mx:DataGridColumn headerText="email" columnName="email" />
    </mx:Array>
    </mx:columns>
    </mx:DataGrid>
    </mx:VBox>
    <mx:HBox>
    <mx:VBox>
    <mx:Label text="id" />
    <mx:TextInput id="name" text="{dg.selectedItem.id}"/>
    </mx:VBox>
    </mx:HBox>
    <!--<mx:Label text="{employeeSrv.result.employees.employee[0].id}"
    visible="true" id="check" /> -->
    <mx:Label text="Phone" />
    <mx:TextInput id="phone" text="{dg.selectedItem.phone}"/>
    <mx:Label text="Email" />
    <mx:TextInput id="email" text="{dg.selectedItem.email}"/>
    <mx:ControlBar width="380" height="39" >
    <mx:Button label="Add" click="addRow()" width="20" height="20"/>
    <mx:Button label="edit" click="updateRow()"/>
    <mx:Button label="delete" click="deleteRow()"/>
    </mx:ControlBar>
    </mx:Panel>
    </mx:Application>

    ************************************************** **************

    ckshah Guest

  2. Similar Questions and Discussions

    1. advice needed... cf write data to xml file for use in flash app thatuses xml file
      I'm wondering if it is possible to use CF to: 1) connect to existing db; 2) get specific data from table; 3) write it to an xml file that would...
    2. LWP - multipart/form-data file upload from scalar rather than local file
      I'm looking to do an HTTP upload, preferably with HTTP::Request::Common, but get the file data from either a filehandle or a scalar rather than...
    3. CSV file to datagrid, data missing & funny character
      Hi, I'm trying to import data from a CSV file to a dataset, then trying to add this to a datagrid. Problem is the datagrid is only displaying...
    4. Sorting a Datagrid that gets data from an XML file
      Hi: All the examples that I see for sorting are for tables that get data from tables. How do I sort my Datagrid that gets data from a dataset...
    5. export datagrid data to Excel file
      is it possible to export excel directly from ASP.NET to Excel? My requirement is that the data on the datagrid is exported to MS Excel file after...
  3. #2

    Default Re: problem in binding xml file data to datagrid xmlfile is generated through JSP file

    Cal the JSP form a browser. You will either get good xml, or you will see an error that will help you debug.

    Tracy
    ntsiii Guest

  4. #3

    Default Re: problem in binding xml file data to datagrid xmlfile is generated through JSP file

    Also, put this at the top of the jsp file:
    response.setContentType("text/xml");

    ntsiii Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139