hi, guys,
my gwt-ext application need to load data to a chart. i use a php file to
read data from my local MySQL server. however in both hosted mode and web
mode, the php file return itself instead of JSON data. if i deploy the whole
application to my apache server, php file can return JSON data. my guess is
the embedded tomcat doesn't enable local mysql server, my question is how
can i make tomcat and mysql work together so i can debug my gwt-ext
application in eclipse? Thanks!!!!
i post my code as below:
*php file : (which is save at /public/data/ directory) *
<?php
header('Content-Type: text/javascript');
echo '{';
echo "\"rates\":";
echo '[';
$link = mysql_connect('localhost', 'root', 'hello');
mysql_select_db('hoana');
$query = 'select * from hrrr limit 3';
$result = mysql_query($query);
$i = 0;
while($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo '{';
echo "\"step\":\"$row[0]\",";
echo "\"rate\":\"$row[1]\"";
echo '}';
if($i < (mysql_num_rows($result)-1)) {
echo ',';
}
$i++;
}
echo ']';
echo '}';
mysql_free_result($result);
mysql_close($link);
?>
*JSON returned:*
{"rates":[{"step":"0","rate":"14.88"},{"step":"1","rate":"14.39"},{"step":"2","rate":"14.01"}]}
*gwt-ext code:
* HttpProxy dataProxy = new HttpProxy("data/getData1.php");
final RecordDef recordDef = new RecordDef(new
FieldDef[]{
new StringFieldDef("step"),
new FloatFieldDef("rate")
});
JsonReader reader = new JsonReader(recordDef);
reader.setRoot("rates");
Store store = new Store(dataProxy, reader);
store.load();
SeriesDefY[] seriesDef = new SeriesDefY[]{
new SeriesDefY("rate", "rate")
};
NumericAxis currencyAxis = new NumericAxis();
currencyAxis.setMinimum(5);
//currencyAxis.setMaximum(35);
currencyAxis.setLabelFunction("formatCurrencyAxisLabel");
LineChart chart = new LineChart();
chart.setWMode("transparent");
chart.setStore(store);
chart.setSeries(seriesDef);
chart.setXField("step");
chart.setYAxis(currencyAxis);
chart.setDataTipFunction("getDataTipText");
chart.setExpressInstall("js/yui/assets/expressinstall.swf");
chart.setWidth(500);
chart.setHeight(400);
*...
*
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"GWT-Ext Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/gwt-ext?hl=en
-~----------~----~----~----~------~----~------~--~---