Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
ckshah #1
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
-
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... -
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... -
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... -
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... -
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... -
ntsiii #2
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
-
ntsiii #3
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



Reply With Quote

