Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Newb With SQL Problems

[ Edited ]

Alrite, we're gonna try some debugging now. the code below will trace back to the debugger (flash builder) the contents of your table out of the siteData object using the trace function and the foreach function of an array:

 

 

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="1024" height="600" backgroundColor="#717171"
creationComplete="onCreationComplete()" currentState="New">
<s:states>
<s:State name="Home"/>
<s:State name="New"/>
<s:State name="Sites"/>
</s:states>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

private var connection:SQLConnection;

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

private function onCreationComplete():void
{
var dbFile:File = File.applicationStorageDirectory.resolvePath("NetworkSites.db");

connection = new SQLConnection();
connection.open ( dbFile );

var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "CREATE TABLE IF NOT EXISTS SITES (SITE_ID INTEGER PRIMARY KEY AUTOINCREMENT, SITENAME TEXT, ACCOUNTNUMBER TEXT, EXTERNALIP TEXT)"
statement.execute();

refreshNetworkSites();

}

private function refreshNetworkSites():void
{
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "SELECT * FROM SITES";
statement.execute();

siteData.source = statement.getResult().data;

siteData.toArray().forEach(traceArray);

function traceArray(element:*, index:int, arr:Array):void
{
trace("Site Name: " + element.SITENAME + ", Account Number: " + element.ACCOUNTNUMBER + ", External IP: " + element.EXTERNALIP);
}


}

private function addSite():void
{
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "INSERT INTO SITES (SITENAME, ACCOUNTNUMBER, EXTERNALIP) VALUES (?, ?, ?)";
statement.parameters[0] = SiteName.text;
statement.parameters[1] = AccountNumber.text;
statement.parameters[2] = ExternalIP.text;
statement.execute();
refreshNetworkSites();
}
]]>
</fx:Script>

<fx:Declarations>

</fx:Declarations>

<s:TextInput id="SiteName" text="Site Name" width="200" x="10" y="10" height="50" fontSize="18" fontWeight="bold" includeIn="New"/>
<s:TextInput id="AccountNumber" text="Account Number" width="200" x="218" y="40" includeIn="New"/>
<s:TextInput x="10" y="147" id="ExternalIP" height="36" fontSize="22" text="External IP" fontWeight="normal" fontFamily="Arial" width="184" includeIn="New"/>

<s:Button x="800" y="10" label="Save" width="103" height="52" id="Save" fontSize="28" fontWeight="bold" includeIn="New" click="addSite()" />
<s:Button x="911" y="10" label="Home" width="103" height="52" id="Home" fontSize="28" fontWeight="bold" includeIn="New,Sites" click="currentState = currentState=='Home' ? '':'Home';" />
<s:Button includeIn="Home" x="99" y="164" label="New Site" width="199" height="87" id="New" fontSize="36" click="currentState = currentState=='New' ? '':'New';" />
<s:Button includeIn="Home" x="312" y="164" label="View Sites" width="199" height="87" id="SitesBTN" fontSize="36" click="currentState = currentState=='Sites' ? '':'Sites';" />

<mx:DataGrid includeIn="New, Sites" x="200" y="300" width="535" height="225" id="SiteGrid" dataProvider="{siteData}">
<mx:columns>
<mx:DataGridColumn headerText="Site Name" dataField="SITENAME"/>
<mx:DataGridColumn headerText="Account Number" dataField="ACCOUNTNUMBER"/>
<mx:DataGridColumn headerText="External IP" dataField="EXTERNALIP"/>
</mx:columns>
</mx:DataGrid>

</s:WindowedApplication>

 

let me know what the output says. good luck (again hah)!

 

Edit: also on a side note are you running this on Desktop AIR Applictaion Test?

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 350
Registered: ‎01-21-2011
My Device: Curve 8900 (Personal) / Bold 9650 (Work)
My Carrier: Regional

Re: Newb With SQL Problems

Correct, I'm not pushing it to the PlayBook.  When I tried running your latest code and saving, there was no output in Flash Builder when I save it.

 

Now, something I did notice, however, is suddenly I'm getting this error:

 

Description	Resource	Path	Location	Type
BlackBerry Tablet OS SDK 0.9.2 for Adobe AIR: mxmlc.jar not found in classpath of C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\blackberry-tablet-sdk-0.9.2.	Network Builder		Unknown	Flex Problem

 

That's just in the Problem output, that doesn't show up at all when I run it.

 

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Newb With SQL Problems

hey,

 

the trace should only output when you run the application and then again when you add a new item into your list via the appliction 'save' button. im not too sure why you are getting that problem message but since it doesnt effect your compiling dont think its much of an issue till you get this one out of hte way.

 

check your console after you open your application via the debug mode and then again when you add a new item to the list. make sure you are in debug and not in run mode. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 350
Registered: ‎01-21-2011
My Device: Curve 8900 (Personal) / Bold 9650 (Work)
My Carrier: Regional

Re: Newb With SQL Problems

I'm in Flash Debug, and I Run Debug, but nothing in console other than loading/unloading the file.

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Newb With SQL Problems

hmm thats strange that you cant see the debug data in your console. here's what we're going to try to do. instead we're going to ouput the contents of your database to a textarea object on screen. the following code will do just that:

 

 

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="1024" height="600" backgroundColor="#717171"
creationComplete="onCreationComplete()" currentState="New">
<s:states>
<s:State name="Home"/>
<s:State name="New"/>
<s:State name="Sites"/>
</s:states>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

private var connection:SQLConnection;

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

private function onCreationComplete():void
{
var dbFile:File = File.applicationStorageDirectory.resolvePath("NetworkSites.db");

connection = new SQLConnection();
connection.open ( dbFile );

var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "CREATE TABLE IF NOT EXISTS SITES (SITE_ID INTEGER PRIMARY KEY AUTOINCREMENT, SITENAME TEXT, ACCOUNTNUMBER TEXT, EXTERNALIP TEXT)"
statement.execute();

refreshNetworkSites();

}

private function refreshNetworkSites():void
{
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "SELECT * FROM SITES";
statement.execute();

siteData.source = statement.getResult().data;

debugData.text = "";

siteData.toArray().forEach(traceArray);

function traceArray(element:*, index:int, arr:Array):void
{
trace("Site Name: " + element.SITENAME + ", Account Number: " + element.ACCOUNTNUMBER + ", External IP: " + element.EXTERNALIP);
debugData.text = debugData.text + "Site Name: " + element.SITENAME + ", Account Number: " + element.ACCOUNTNUMBER + ", External IP: " + element.EXTERNALIP + "\n";
}


}

private function addSite():void
{
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "INSERT INTO SITES (SITENAME, ACCOUNTNUMBER, EXTERNALIP) VALUES (?, ?, ?)";
statement.parameters[0] = SiteName.text;
statement.parameters[1] = AccountNumber.text;
statement.parameters[2] = ExternalIP.text;
statement.execute();
refreshNetworkSites();
}
]]>
</fx:Script>

<fx:Declarations>

</fx:Declarations>

<s:TextInput id="SiteName" text="Site Name" width="200" x="10" y="10" height="50" fontSize="18" fontWeight="bold" includeIn="New"/>
<s:TextInput id="AccountNumber" text="Account Number" width="200" x="218" y="40" includeIn="New"/>
<s:TextInput x="10" y="147" id="ExternalIP" height="36" fontSize="22" text="External IP" fontWeight="normal" fontFamily="Arial" width="184" includeIn="New"/>

<s:Label id="debugLabel" width="600" height="52" fontFamily="Arial" fontSize="16" text="siteData Contents:" x="200" y="95" includeIn="New" color="0xFFFFFF" />
<s:TextArea id="debugData" y="147" x="200" height="150" width="800" fontSize="14" fontFamily="Arial" includeIn="New" />

<s:Button x="800" y="10" label="Save" width="103" height="52" id="Save" fontSize="28" fontWeight="bold" includeIn="New" click="addSite()" />
<s:Button x="911" y="10" label="Home" width="103" height="52" id="Home" fontSize="28" fontWeight="bold" includeIn="New,Sites" click="currentState = currentState=='Home' ? '':'Home';" />
<s:Button includeIn="Home" x="99" y="164" label="New Site" width="199" height="87" id="New" fontSize="36" click="currentState = currentState=='New' ? '':'New';" />
<s:Button includeIn="Home" x="312" y="164" label="View Sites" width="199" height="87" id="SitesBTN" fontSize="36" click="currentState = currentState=='Sites' ? '':'Sites';" />

<mx:DataGrid includeIn="New, Sites" x="200" y="300" width="535" height="225" id="SiteGrid" dataProvider="{siteData}">
<mx:columns>
<mx:DataGridColumn headerText="Site Name" dataField="SITENAME"/>
<mx:DataGridColumn headerText="Account Number" dataField="ACCOUNTNUMBER"/>
<mx:DataGridColumn headerText="External IP" dataField="EXTERNALIP"/>
</mx:columns>
</mx:DataGrid>

</s:WindowedApplication>

 

let me know what you find. good luck!

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 350
Registered: ‎01-21-2011
My Device: Curve 8900 (Personal) / Bold 9650 (Work)
My Carrier: Regional

Re: Newb With SQL Problems

Okay, I don't know what the deal is.  I see your text area in the source, I see it in the design view, I don't see it when running the app.  I even deleted the other two states and still don't see it.

 

Flex hates me.

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Newb With SQL Problems

hmm thats really strange. but from the sound of it your app isnt compiling and you are just seeing the older version of it. i want you to do something really drastic like change the background and see if the background changes after you hit debug. if it doesnt that means your app isnt compiling properly. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 350
Registered: ‎01-21-2011
My Device: Curve 8900 (Personal) / Bold 9650 (Work)
My Carrier: Regional

Re: Newb With SQL Problems

Made it blood red, loaded the bland gray.

 

Figures lol

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Newb With SQL Problems

hah interesting choice of colors Smiley Very Happy

 

alrite so i guess that mxmlc.jar problem that came up was a bigger deal than i thought. sounds like your SDK is broken somehow. cant see why though. browse to the blackberry 0.9.2 director and see if the mxmlc file is there. you might need to restart your computer to flush out any bugs in the flash builder program and try to compile again and see if that clears things up. worse comes to worst you will have to re-install your blackberry sdk. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Highlighted
Developer
Posts: 350
Registered: ‎01-21-2011
My Device: Curve 8900 (Personal) / Bold 9650 (Work)
My Carrier: Regional

Re: Newb With SQL Problems

Wow, so I made a new Flex Project, copied/pasted the code in and hit run.  Adobe blew up.  I need to sit down and maybe reinstall the SDK?

 

AdobeHatesMe.PNG