some URL`s like http://www.flexgrocer.com/categorySalesData.xml are erroneous

81 views
Skip to first unread message

BabyPowder

unread,
Jun 17, 2010, 7:41:59 AM6/17/10
to Flex 3:Training from the Source
I tried to get through the Flex 3 Trainingbook, I am now at unit 19
but I can`t see any charts.....when I try to lookup the HTTPService
links which should fill the charts with data I get xml error and my
charts are empty I just can see the text "Flex Data Vizualisation
Trial" that`s it

can anybody help or has the same Problem?

Michael Labriola

unread,
Jun 17, 2010, 7:48:47 AM6/17/10
to Flex 3:Training from the Source

What makes you believe the URL is erroneous instead of an error
elsewhere in the entered code?

I took the URL you mention in the title, put it into a web browser and
it opens immediately. Doesn't seem to be a problem there.

http://www.flexgrocer.com/categorySalesData.xml (for reference)

If you are using Chrome or Safari, you may need to view source to see
the XML, but that is a factor of the browser, not the data.
Mike

BabyPowder

unread,
Jun 17, 2010, 8:01:33 AM6/17/10
to Flex 3:Training from the Source
Thank you for the quick response first

Sorry the Link I posted was wrong, that one is working and is ok like
you said but how about these ones:

http://www.flexgrocer.com/rawSalesData.xml

http://www.flexgrocer.com/salesData.xml

When I run Dashboard.xml I can`t see any data


On 17 Jun., 13:48, Michael Labriola <malabri...@gmail.com> wrote:
> What makes you believe the URL is erroneous instead of an error
> elsewhere in the entered code?
>
> I took the URL you mention in the title, put it into a web browser and
> it opens immediately. Doesn't seem to be a problem there.
>
> http://www.flexgrocer.com/categorySalesData.xml(for reference)

Michael Labriola

unread,
Jun 17, 2010, 8:04:45 AM6/17/10
to Flex 3:Training from the Source

When I copy and paste those links into a web browser, I receive XML.

I am guessing the bug you are looking for is elsewehre

BabyPowder

unread,
Jun 17, 2010, 8:12:56 AM6/17/10
to Flex 3:Training from the Source
I am receiving this message when I try to lookup the two links

XML processing error: XML or text declaration not at start of entity
Address: http://www.flexgrocer.com/rawSalesData.xml
Line 2, column 1: <xml version = "1.0" encoding = "utf-8"?
^

When I try the files from the CD of the Book I have the same issue so
I can`t find any bug on my side

Michael Labriola

unread,
Jun 17, 2010, 8:14:32 AM6/17/10
to Flex 3:Training from the Source

What browser are you using/ I will try to replicate it for you on this
side.

BabyPowder

unread,
Jun 17, 2010, 8:15:27 AM6/17/10
to Flex 3:Training from the Source
I am receiving this message when I try to lookup the two links

XML processing error: XML or text declaration not at start of entity
Address: http://www.flexgrocer.com/rawSalesData.xml
Line 2, column 1: <xml version = "1.0" encoding = "utf-8"?
^

When I try the files from the CD of the Book I have the same issue so
I can`t find any bug on my side

May can post me the XML that you can see, so I can copy and paste them
to a local XML file and can give a try what happens


On 17 Jun., 14:04, Michael Labriola <malabri...@gmail.com> wrote:

BabyPowder

unread,
Jun 17, 2010, 8:21:24 AM6/17/10
to Flex 3:Training from the Source
Okay, I got it!

the failure is in Firefox.......it`s showed me other XML sides without
any problems.....
when I open the two links with the IE I can see the XML.....so why I
can`t see any charts?

Like I said I used as well the files from the CD and just can see the
text "Flex Data Visualization Trial" in the windows/boxes with the
scales.
When I click the DATA button it is empty

Michael Labriola

unread,
Jun 17, 2010, 8:35:42 AM6/17/10
to Flex 3:Training from the Source
Because the xml is a red herring that you have become focused upon. I
guarantee there is some other small mistake that is causing the
problem. Have you compared your files against the known good files for
the end of the lesson on your cd?

If you would like to post your code, I am happy to take a look too

Mike

BabyPowder

unread,
Jun 17, 2010, 8:38:44 AM6/17/10
to Flex 3:Training from the Source
I copied the good files from the CD and same problem

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:v="views.dashboard.*"
layout="horizontal"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;

[Bindable]
private var categories:ArrayCollection=new ArrayCollection();

private function catHandler(event:ResultEvent):void{
categories = event.result.catalog.category;
var catObj:Object = new Object();
catObj.name = "All";
catObj.categoryID = 0;
categories.addItemAt(catObj, 0);
catCombo.selectedIndex = 0;
}

private function salesRPCResult(event:ResultEvent):void{
sales.dp = event.result.salesData.dailySales;
}

private function typeRPCResult(event:ResultEvent):void{
type.dp = event.result.categorySalesData.categorySales;
}

private function compRPCResult(event:ResultEvent):void{
comp.dp = event.result.salesData.dailySales;
}

private function showFault(event:FaultEvent):void{
trace(event.fault.faultCode+":"+event.fault.faultString);
}

private function getData():void{
salesRPC.send();
typeRPC.send();
compRPC.send();
}

private function init():void{
startDate.selectedDate = new Date(2006,3,1);
endDate.selectedDate = new Date(2006,4,1);
catRPC.send();
getData();
}

]]>
</mx:Script>

<mx:HTTPService id="salesRPC"
url="http://www.flexgrocer.com/rawSalesData.xml"
result="salesRPCResult(event)"
fault="showFault(event)"/>
<mx:HTTPService id="typeRPC"
url="http://www.flexgrocer.com/categorySalesData.xml"
result="typeRPCResult(event)"
fault="showFault(event)"/>
<mx:HTTPService id="compRPC"
url="http://www.flexgrocer.com/salesData.xml"
result="compRPCResult(event)"
fault="showFault(event)"/>

<mx:HTTPService id="catRPC"
url="http://www.flexgrocer.com/category.xml"
result="catHandler(event)"/>

<mx:ApplicationControlBar dock="true">
<mx:Label text="Start Date"/>
<mx:DateField id="startDate"/>
<mx:Label text="End Date"/>
<mx:DateField id="endDate"/>
<mx:Spacer width="100%"/>
<mx:ComboBox id="catCombo"
dataProvider="{categories}"
labelField = "name"/>
<mx:Spacer width="100%"/>
<mx:RadioButtonGroup id="grossOrNetGroup"/>
<mx:RadioButton id="gross"
groupName="grossOrNetGroup"
label="Gross Sales"
data="GROSS"
selected="true"/>
<mx:RadioButton id="net"
groupName="grossOrNetGroup"
label="Net Sales"
data="NET"/>
</mx:ApplicationControlBar>

<mx:states>
<mx:State name="fullSales">
<mx:SetProperty target="{rightCharts}"
name="width" value="0"/>
<mx:SetProperty target="{rightCharts}"
name="height" value="0"/>
</mx:State>

<mx:State name="fullType">
<mx:SetProperty target="{sales}"
name="width"
value="0"/>
<mx:SetProperty target="{sales}"
name="height"
value="0"/>
<mx:SetProperty target="{comp}"
name="width"
value="0"/>
<mx:SetProperty target="{comp}"
name="height"
value="0"/>
</mx:State>
<mx:State name="fullComp">
<mx:SetProperty target="{sales}"
name="width"
value="0"/>
<mx:SetProperty target="{sales}"
name="height"
value="0"/>
<mx:SetProperty target="{type}"
name="width"
value="0"/>
<mx:SetProperty target="{type}"
name="height"
value="0"/>
</mx:State>
</mx:states>

<v:SalesChart id="sales"
width="100%" height="100%"
title="Sales Chart"
grossOrNet="{grossOrNetGroup.selection.data}"
maximize="this.currentState='fullSales'"
restore="this.currentState=''">
</v:SalesChart>
<mx:VBox id="rightCharts"
width="100%" height="100%" >
<v:TypeChart id="type"
width="100%" height="100%"
title="Category Chart"
grossOrNet="{grossOrNetGroup.selection.data}"
maximize="this.currentState='fullType'"
restore="this.currentState=''">
</v:TypeChart>
<v:ComparisonChart id="comp"
width="100%" height="100%"
title=" Comparison Chart"
maximize="this.currentState='fullComp'"
restore="this.currentState=''">
</v:ComparisonChart>
</mx:VBox>
</mx:Application>

and here is one of the charts

<?xml version="1.0" encoding="utf-8"?>
<v:MaxRestorePanel
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:v="views.*" >
<mx:Script>
<![CDATA[
import mx.charts.HitData;
import mx.collections.ArrayCollection;

import mx.controls.dataGridClasses.DataGridColumn;
import mx.collections.ICollectionView;

[Bindable]
public var dp:ICollectionView = null;

[Bindable]
public var grossOrNet:String;

/*
DataGrid label functions
*/

private function renderDGDate(item:Object,
col:DataGridColumn):String{
return mmddyyyy.format(item[col.dataField]);
}
private function renderDGDollars(item:Object,
col:DataGridColumn):String{
return dollars.format(item[col.dataField]);
}

private function renderDate(value:Object,
previousValue:Object,axis:CategoryAxis, item:Object):String{
return mmddyyyy.format(value);
}

private function renderTips(hd:HitData):String {
var item:Object = hd.item;
return "<b>" + mmddyyyy.format(item.DTSALE) + "</b><br>" +
dollars.format(item[grossOrNet]);
}

]]>
</mx:Script>
<mx:DateFormatter id="mmddyyyy" formatString="MM/DD/YYYY" />
<mx:CurrencyFormatter id="dollars" />
<mx:ViewStack id="chartStack" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:LineChart id="chart"
dataProvider="{dp}"
height="100%" width="100%"
showDataTips="true"
dataTipFunction="renderTips">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="DTSALE" id="catAxis"
labelFunction="renderDate"/>
</mx:horizontalAxis>
<mx:series>
<mx:LineSeries yField="{grossOrNet}">
</mx:LineSeries>
</mx:series>
</mx:LineChart>
</mx:VBox>
<mx:VBox width="100%" height="100%">
<mx:DataGrid dataProvider="{dp}" width="100%" height="100%" >
<mx:columns>
<mx:DataGridColumn dataField="DTSALE"
headerText="Sale Date"
labelFunction="renderDGDate"/>
<mx:DataGridColumn dataField="NET"
headerText="Profit"
labelFunction="renderDGDollars"/>
<mx:DataGridColumn dataField="GROSS"
headerText="Gross Sales"
labelFunction="renderDGDollars"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:ViewStack>

<mx:ControlBar id="controls">
<mx:Button label="Graph" id="btGraph"
click="chartStack.selectedIndex=0"/>
<mx:Button label="Data" id="btData"
click="chartStack.selectedIndex=1"/>
</mx:ControlBar>
</v:MaxRestorePanel>

Michael Labriola

unread,
Jun 17, 2010, 9:43:00 AM6/17/10
to Flex 3:Training from the Source

You mention in your post this is lesson 19, but your code isn't close
to the code for 19,18 or even 17. It looks like the code for 16 with
some minor changes. Could you please confirm the lesson you are
working with?

Also, are you working with an English copy or a translation, I just
want to make sure there wasn't a change in lesson numbering. Compared
to my 18, your code is still using HTTPService and not Webservices,
which is a big change.

In addition to that, if I run your Application.mxml file and set a
break point at each of the result methods, I receive data back with
your code.

Finally, I loaded the completed code for 16 and 17 and ran it
successfully on my machine in all browsers. In Lesson 18, you are
instructed to begin modifying this code to work off your local
machine, and no longer from flexgrocer.com. This again points to the
fact that either your code is not from 19, or you have missed a few
lessons worth of steps.

I am glad to help you, but the information being provided at this
point is not consistent and I need to understand where we are mis-
communicating.

Mike
Reply all
Reply to author
Forward
0 new messages