Appcelerator Titanium Cookbook - Errata & Explanations

Appcelerator Titanium Cookbook - Errata & Explanations

January 1, 2012

Whilst every attempt was made to ensure the code and content of the book was 100% accurate, we all know this can never be the case (particularly with how rapidly Titanium and mobile development in general changes!). So if you've found a mistake or would like something explained in more detail in relation to my Appcelerator Titanium Cookbook, please post a message here and I'll endevour to respond and fix any errors.

Note that I am pretty busy so I can't always respond straight away but I will try to get back to everyone as quickly as I can.


Learningtocode

Posts: 39
Comment
invalid SQL statement. Error (Ch 2 recipe 7)
Reply #42 on : Fri December 28, 2012, 17:43:51
Thank you for reading my question. My question is regarding Appcelerator-Titanium-Smartphone-App-Development-Cookbook Chapter 2 – Recipe 7.

Book: Appcelerator-Titanium-Smartphone-App-Development-Cookbook

Chapter: Recipe 7 – Chapter 2.

Background: Currently I have code in my recipes.js file which is suppose to populate my database.js file.
Here is what the code loos like:
//create table view row. The data from this row is to populate //the database.
var row = Titanium.UI.createTableViewRow({
hasChild: true,
className: 'recipe-row',
backgroundColor: '#fff',
filter: jsonObject.query.results.item[i].title,
_title: jsonObject.query.results.item[i].title,
_description: jsonObject.query.results.item[i].description,
_link: jsonObject.query.results.item[i].link
//this is the data we want to search on (title)
})
~~~~~
//Here is how I call the data for it to be populated into the SQL Database.
//When I try to populate the database with stings, it works fine, however when I try //to populate it as a


//create a new window and pass through data from the tapped row
tblRecipes.addEventListener('click', function(e){
var selectedRow = e.rowData; //row index clicked
var detailWindow = Titanium.UI.createWindow({
title: selectedRow._title,
_description: selectedRow._description,
_link: selectedRow._link,
backgroundColor: '#fff',
id: 0
});

//add the favorite button
var favButton = Titanium.UI.createButton({
title: 'Add Favorite',
left: 10,
top: 10,
width: 140,
height: 30,
added: 0
});
favButton.addEventListener('click',function(e){
if (favButton.added == 0) {
var newId = insertFavorite(detailWindow.title, detailWindow._description, detailWindow._link);
Ti.API.info('Newly created favorite id = ' + newId);
detailWindow.id = newId;
alert('This recipe has been added as a favorite!');
favButton.added = 1;
favButton.title = 'Remove Favorite';
}
else {
deleteFavorite(detailWindow.id);
Ti.API.info('Deleted ' + affectedRows + ' favorite records. (id ' + detailWindow.id + ')');
detailWindow.id = 0;
alert('This recipe has been removed from favorites!');
favButton.added = 0;
favButton.title = 'Add Favorite';
}
});
detailWindow.add(favButton);

//let's also add a button to open a link in safari
var linkButton = Titanium.UI.createButton({
title: 'View In Safari',
right: 10,
top: 10,
width: 140,
height: 30,
added: 0
});
//this event listener will open the link in safari
linkButton.addEventListener('click',function(e){
Ti.Platform.openURL(detailWindow._link);
});
detailWindow.add(linkButton);

//finally, add the full description so we can read the whole recipe
var lblDescription = Titanium.UI.createLabel({
text: detailWindow._description,
left: 10,
top: 50,
width: 300,
height: 'auto',
color: '#000'
});
detailWindow.add(lblDescription);

//open the detail window
Titanium.UI.currentTab.open(detailWindow);
});

//////////////////


Problem: When I try to populate the database I get the following error:

[ERROR] invalid SQL statement. Error Domain=com.plausiblelabs.pldatabase Code=3 "An error occured parsing the provided SQL statement.

Note: I do not get this error when I use the following code, however I do not get the results I want either. Meaning, the database populates but with strings.

//create a new window and pass through data from the tapped row
tblRecipes.addEventListener('click', function(e){
var selectedRow = e.rowData; //row index clicked
var detailWindow = Titanium.UI.createWindow({
title: 'selectedRow._title',
_description: 'selectedRow._description',
_link: 'selectedRow._link',

Instead of:

title: selectedRow._title,
_description: selectedRow._description,
_link: selectedRow._link,
backgroundColor: '#fff',
id: 0
});


~~~~

Please help?

Brendan Jefferis
Posts: 39
Comment
Re: affectedRows (Ch 2 recipe 7) links
Reply #41 on : Tue November 06, 2012, 21:05:23
Apologies, embedding is disabled here. Pastie links as follows:

From: Database.js
http://pastie.org/5338207

From: Recipes.js (favButton.addEventListener, if/else block)
http://pastie.org/5338182

Brendan Jefferis
Posts: 39
Comment
Re: affectedRows (Ch 2 recipe 7)
Reply #40 on : Tue November 06, 2012, 21:01:27
@Oskar @andrew

In the book, affectedRows has not been declared/set anywhere so it will return undefined.

I searched the appcelerator docs and found a property of Ti.Database.DB called rowsAffected, which I am guessing the author was intending to use (?)

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Database.DB-property-rowsAffected

My solution for this was to add a callback function to deleteFavorites() in database.js to capture the db.rowsAffected property…



Then call an anonymous function as an argument of deleteFavorite in Recipes.js, and set the callback data (db.rowsAffected) to affectedRows…



As usual, corrections, advice or suggestions are more than welcome.

Brendan Jefferis
Posts: 39
Comment
Ch 2: Local/Remote Data Sources "description"
Reply #39 on : Sun November 04, 2012, 19:09:40
I used 'http://www.taste.com.au/feeds/latest+recipes.xml' as the xml feed, but the description property returns a bunch of HTML junk with the actual description, i.e.

"description": "<a href=\"http://www.taste.com.au/recipes/28892/beef+singapore+curry\"><img src=\"http://cdn.taste.com.au/images/recipes/sfi/2012/02/28892_m.jpg\" alt=\"Beef Singapore curry\" title=\"Beef Singapore curry\" class=\"image\" /></a><br/>Beef and potato is lovingly stewed until tender and juicy..."

YQL link here: http://y.ahoo.it/bSnEg

My current solution is to use string.substr and string.lastIndexOf to only get the string content after that last <br/>, i.e.,

var source = jsonObject.query.results.item[i].description;
var description = source.substr(source.lastIndexOf(">") + 1);

This works, but seems like a bit of a hack fix (if the feed content provider omitted that <br/> it'd get messed up etc), is there a cleaner way to tidy up messy remote data?

Cheers
Brendan

Oskar
Posts: 39
Comment
Ch 2 recipe 7
Reply #38 on : Mon September 03, 2012, 03:05:00
I keep getting this when i press "remove favorite"

[WARN] Exception in event callback. {
line = 79;
message = "Can't find variable: affectedRows";
name = ReferenceError;
sourceId = 262200800;
sourceURL = "file://localhost/Users/Oskar/Library/Application%20Support/iPhone%20Simulator/5.1/Applications/3AA98164-9E16-416F-87F4-CE2611594E69/MyRecipes.app/recipes.js";
}

Michael Gardner
Posts: 39
Comment
Titanium and Urban Airship
Reply #37 on : Mon August 13, 2012, 23:09:14
Entered the code from your cookbook and the push notification works, however when I tap on the alert, it brings up the app and says "No APS Content"

When I comment out that part because the test broadcast from UA's website doesn't have a "body" component, and send another one, now I get "No alert message" and I can see the alert component in it.

what am I doing wrong?

Boydlee Pollentine
Posts: 39
Comment
RE: Dragging the ImageView
Reply #36 on : Thu August 09, 2012, 03:15:57
Hi,

Sorry for such a late reply - I've actually been on holiday and out of Internet reach for over a week.

The solution you have is correct. Basically, recent versions of the Titanium Mobile API have removed the "globalPoint" parameters that were originally used to do the dragging when I wrote the book, hence the reason it no longer works as it should.

Thanks for sharing your solution with everyone!

Boydlee

Andi
Posts: 39
Comment
Dragging the ImageView - SOLUTION
Reply #35 on : Sun August 05, 2012, 17:20:53
After two days of trying to figure out the issue I posted about below, I came up with a solution that seems to be working well. The following code can be used to replace the code supplied on Page 178 which sets the center point for the dragging animation.

imageViewFace.addEventListener('touchmove', function(e) {
Ti.API.debug('Our event tells us the center is ' + e.x + ', ' + e.y );
imageViewMe.left = e.x + imageViewFace.animatedCenter.x - imageViewMe.width;
imageViewMe.top = e.y + imageViewFace.animatedCenter.y - imageViewMe.height;
imageViewMe.animate({left:imageViewMe.left, top:imageViewMe.top, duration:1});
});


Boydlee... if there are issues with this code or if there is a better solution to this problem, please let us know.

Andi
Posts: 39
Comment
Andrew... question...
Reply #34 on : Sun August 05, 2012, 16:47:58
Andrew... could you be more specific about what you are asking in regards to the "affected rows" in Chapter 2?

Andi
Posts: 39
Comment
Dragging the ImageView
Reply #33 on : Sun August 05, 2012, 16:45:19
I am having some issues with the section on Dragging the ImageView using touch events in Chapter 7 now.
When I run the downloaded app.js file that is supplied, the dragging function doesn't work there either.

Specifically, when I enter the code from page 178, the dragging function works. However, when I replace it with that code to center the dragging position (with the code on page 179), it stops working completely.

Ive tried adapting the code from the Kitchen Sink examples but since it doesn't include the 'touchstart' code it is jumpy as described it would be in the text.

Any suggestions... or has anyone else run into this problem?

andrew
Posts: 39
Comment
Problem with chapter 2 - the _title stuff
Reply #32 on : Wed July 25, 2012, 18:39:54
Hey,

in chapter 2 section 7, where is the "affectedRows" value set?

Andi
Posts: 39
Comment
Chapter 3, Recipe 3 Correction
Reply #31 on : Thu July 19, 2012, 13:31:38
In the book's example code, the searchview is not added to the window. To correct the error, add the following line of code right before creating your map view.

//add the search view to our window
win1.add(searchview);

Andi
Posts: 39
Comment
Errors in Chapter 2...
Reply #30 on : Mon July 16, 2012, 02:13:07
Nevermind. I worked through the Chapter again from the beginning and found my errors.

Andi
Posts: 39
Comment
Chapter 2...
Reply #29 on : Mon July 16, 2012, 01:44:52
I keep getting an error on the second recipe of Chapter 2. My recipes.js file is getting an error that says it can't find the variable "win" on line 14 (which is the win.add(tblRecipes); line)

Currently my code for that file reads...


//declare the http client object
var xhr = Titanium.Network.createHTTPClient();

var data = []; //empty data array

//create the table view
var tblRecipes = Titanium.UI.createTableView({
height: 366,
width: 320,
top: 0,
left: 0
});

win.add(tblRecipes);

//this method will process the remote data
xhr.onload = function() {
var xml = this.responseXML;

//get the item nodelist from our response xml object
var items = xml.documentElement.getElementsByTagName("item");

//loop each item in the xml
for (var i = 0; i < items.length; i++) {

//create a table row
var row = Titanium.UI.createTableViewRow({
title: items.item(i).getElementsByTagName("title").item(0).text
});

//add the table row to our data[] object
data.push(row);
} //end for loop

//finally, set the data property of the tableView to our data[] object
tblRecipes.data = data;
};

//this method will fire if there's an error in accessing the remote data
xhr.onerror = function() {
//log the error to our titanium developer console
Ti.API.error(this.status + ' - ' + this.statusText);
};

//open up the recipes xml feed
xhr.open('GET', 'http://www.taste.com.au/feeds/latest+recipes.xml');

//finally, execute the call to the remote feed
xhr.send();


Do you have any suggestions as to why I might be getting this error? I see that other people have had issues with this chapter but I'm still having trouble after reading through the discussions.

idarfan
Posts: 39
Comment
about chater5 page 134 issue.
Reply #28 on : Fri July 06, 2012, 00:34:05
Hi Bro,

I followed your instruction in Chapter5: Connecting your Apps with Social Media and E-mail on P.134, details as bellow:

buttonSelectImage.addEventListener('click',function(e){
//obtain an image from the gallery
Titanium.Media.openPhotoGallery({

success:function(event)
{
selectedImage = event.media;

// set image view
Ti.API.debug('Our type was: '+event.mediaType);
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
{
imageThumbnail.image = selectedImage;
}
},
cancel:function()
{
//user cancelled the action fron within
//the photo gallery
}
});
});
win1.add(buttonSelectImage);

About this line : Ti.Media.MEDIA_TYPE_PHOTO, I look up on api doc. As you mention, I know that only works on iOS system. I’ve tried to find the solution on android system, but haven’t figured that out. Currently, I’m developing Android 4.1 System. Can you give me some advice to solve this problem?

Besides, Everytime when I click “Select Image Button” on this line I mentioned, my android will immediately crash without any error message. Hopefully, I can get the satisfy answers from you.



Thanks!

Josh
Posts: 39
Comment
Re: Chapter 2: Saving data locally using a SQLite database
Reply #27 on : Sat June 16, 2012, 03:12:26
I have found the issue.

The sample code printed in the book did not include these three statements in the onload function:

_title: jsonObject.query.results.item[i].title,
_description: jsonObject.query.results.item[i].description,
_link: jsonObject.query.results.item[i].link

Josh
Posts: 39
Comment
Chapter 2: Saving data locally using a SQLite database
Reply #26 on : Sat June 16, 2012, 02:23:41
hi I'm having the same issue, when I click a row in table view it takes me to an empty detail page.
full code is here: http://pastie.org/4096540

Boydlee Pollentine
Posts: 39
Comment
RE: Saving data locally using a SQLite database
Reply #25 on : Wed June 06, 2012, 08:30:04
Please post your code into a GIST or pastie.org and include the database functions you've written.

Low Ko Wee
Posts: 39
Comment
Saving data locally using an SQLite database
Reply #24 on : Wed June 06, 2012, 08:16:52
I follow your code exactly on your cook book but it doesn't work. Could you please advise me.


//create a new window and pass through data from the
//tapped row
tblRecipes.addEventListener('click', function(e){
var selectedRow = e.rowData; //row index clicked
var detailWindow = Titanium.UI.createWindow({
title: selectedRow._title,
_description: selectedRow._description,
_link: selectedRow._link,
backgroundColor: '#fff',
id: 0
});
//add the favorite button
var favButton = Titanium.UI.createButton({
title: 'Add Favorite',
left: 10,
top: 10,
width: 140,
height: 30,
added: 0
});
favButton.addEventListener('click',function(e){
if (favButton.added == 0) {
var newId = insertFavorite(detailWindow.title,
detailWindow._description, detailWindow._link);
Ti.API.info('Newly created favorite id = ' + newId);
detailWindow.id = newId;
alert('This recipe has been added as a favorite!');
favButton.added = 1;
favButton.title = 'Remove Favorite';
}
else {
deleteFavorite(detailWindow.id);
Ti.API.info('Deleted ' + affectedRows +
' favorite records. (id ' + detailWindow.id + ')');
detailWindow.id = 0;
alert('This recipe has been removed from favorites!');
favButton.added = 0;
favButton.title = 'Add Favorite';
}
});
detailWindow.add(favButton);
//let's also add a button to open a link in safari
var linkButton = Titanium.UI.createButton({
title: 'View In Safari',
right: 10,
top: 10,
width: 140,
height: 30,
added: 0
});
//this event listener will open the link in safari
linkButton.addEventListener('click',function(e){
Ti.Platform.openURL(detailWindow._link);
});
detailWindow.add(linkButton);
Working with Local and Remote Data Sources
62
//finally, add the full description so we can read the
//whole recipe
var lblDescription = Titanium.UI.createLabel({
text: detailWindow._description,
left: 10,
top: 50,
width: 300,
height: 'auto',
color: '#000'
});
detailWindow.add(lblDescription);
//open the detail window
Titanium.UI.currentTab.open(detailWindow);
});

Boydlee Pollentine
Posts: 39
Comment
RE: chart.js file not in the example code
Reply #23 on : Tue March 27, 2012, 02:57:46
Hi Amen,

The code for this was actually provided to the publisher a long time ago and they should have either sent it to you or made it available as part of the code download on their website. You can download it directly from here, with the missing file included: http://bit.ly/tIZjqy

Thanks,
Boydlee

Sohn
Posts: 39
Comment
about FourSquare ACCESS_TOKEN (page 217)
Reply #22 on : Sat March 24, 2012, 22:02:16
Hi,
I am a developer from Korea and translating your book into Korean.
Do you remember me?.. i asked something 2month ago,anyways,..

Today, i have another question!
I don't know how many things are changed in Titanium.
I put the code which is on 217 page and run it. but it does't work!
So I tried to trace the code, and i found the reason.

in the "authorizeUICallback(e)", the object "e" have url value.
but the "e.url" value doesn't have a access_token!!!

Here is my console logs

[DEBUG] New scheme: <NSMutableURLRequest https://ko.foursquare.com/oauth2/authenticate?response_type=token&client_id=SCQDRXJQ30WHL5TL21LRHBS2JA4PZQZU30OOHVFVWJRQSP4K&redirect_uri=https://ko.foursquare.com/user/24587760>
[DEBUG] New scheme: <NSMutableURLRequest https://ko.foursquare.com/user/24587760#access_token=0O4H2T3RIRV5AKVOYYRGDH3PFDHI3ECK3I234VXMCJQUFLXU>
[DEBUG] New scheme: <NSMutableURLRequest https://ko.foursquare.com/touch/user/24587760>
[DEBUG] authorizeUILoaded https://ko.foursquare.com/touch/user/24587760
[DEBUG] {
source = "[object TiUIWebView]";
type = load;
url = "https://ko.foursquare.com/touch/user/24587760";
}

---
In this logs, definitely I got the "#access_token=0O4H2T.... " but i don't know how do i use it!
do you have any solution! or do i have to do something in advance?
plz, give me your sight!
thank you.

from Sohn in Korea

Amen Moja Ra
Posts: 39
Comment
chart.js file not in the example code
Reply #21 on : Fri March 23, 2012, 13:46:18
You have very confusing code on the Section 10 of Chapter 1. In the exercise files and even in the complete example I cannot understand what is in the chart.js file because there is no chart.js file.

Boydlee
Posts: 39
Comment
Errate page on publisher's website
Reply #20 on : Thu February 09, 2012, 13:43:17
Hi everyone,

I'm currently compiling a list of errata and fixes to go onto the publishers website, many of the items below will make up part of that so thank you all for finding issues and contributing to the book. I will provide a link to that errata site (and some updated source where required) in the next few days

Peter
Posts: 39
Comment
FlexSpace + buttonDone
Reply #19 on : Thu February 09, 2012, 12:24:36
Early in the book (Recipe 5) we add a 'Done' button to the keyboardToolbar. I have noticed that while this does indeed create the buttons, there is a problem when they are clicked.

Enter a value into the Amount field, then click the Done button, then enter a value into the interest rate field and click the 'Done' button.

When you click back to the Amount field, the 'Done' button is not available.

This works the other way around as well. Essentially, when you use the done button on the 2nd field's keyboardToolbar, it is no longer present on the 1st field's keyboard Toolbar.

Hopefully, you can recreate this and advise of a fix for it.

Thanks in advance.

Amen Moja Ra
Posts: 39
Comment
Chapter 2 errors are chapter 1 errors
Reply #18 on : Wed February 08, 2012, 13:34:00
I apologize the error I was referring to are in chapter one in the section Adding a Tab Group

Amen Moja Ra
Posts: 39
Comment
Chapter 2 errors
Reply #17 on : Wed February 08, 2012, 13:29:26
The problems that users may be having and I am referencing Alexandre's post are probably the result of you not stating that in the window2.js file the following line of code should be included:
var win2 = Titanium.UI.currentWindow;

Once this line of code is place in that file there should be no errors.

admin
Posts: 3
Comment
RE: Chapter 2
Reply #16 on : Tue February 07, 2012, 05:09:01
Hi,

Could you state what those errors are? There is a known issue (as stated on this page) that the RSS Feed listed in the book is now unavailable, however any RSS link will do the job. As an example, you could try www.taste.com.au/feeds/latest+recipes.xml

Alexandre
Posts: 39
Comment
Chapter 2
Reply #15 on : Mon January 30, 2012, 22:12:04
Hi I have some troubles to execute code at chapter two, can you provide the full source code with erros fixed? Thanks.

Liz Myers
Posts: 39
Comment
Ch 7 Persistent Clown
Reply #14 on : Mon January 23, 2012, 07:13:13
transform1 = transform1.rotate(-180);

(problem = clown mask turns upside down, but remains visible. add the following to hide the clown mask)

transform1 = transform1.scale(0);

Liz Myers
Posts: 39
Comment
Chapter 7 Parse Error
Reply #13 on : Mon January 23, 2012, 07:06:37
var imageViewMe = Ti.UI.createImageView({
.
.
.
zIndex: 0
[should be zIndex:0, - the missing comma after the "0" throws up a parse error]
.
.
.


})

Boydlee
Posts: 39
Comment
Additional }, characters on Page 17 / Chapter 1
Reply #12 on : Mon January 23, 2012, 06:37:25
In the code for the "labelAmount" component, there's an additional }, set of characters in the font property.
What reads like:

font: {fontSize: 14, fontFamily: 'Helvetica', fontWeight: 'bold},},

should read like
font: {fontSize: 14, fontFamily: 'Helvetica', fontWeight: 'bold},

Ketan Majmudar
Posts: 39
Comment
Chapter 7 p 171 & 177
Reply #11 on : Sun January 22, 2012, 12:57:30
FYI:

p171
The event handler setChosenImage isn't in the print or the Recipe examples so the example will throw up an error when you try and run it. It just needs an empty function in the eventListener.

p175
The How to do it section references code in Recipe 2 folder, the code is actually in the Recipe 3 folder.

I'll let you know if I find any other issues.

Boydlee
Posts: 39
Comment
RE: Ch 2 - e.rowData properties?
Reply #10 on : Fri January 13, 2012, 04:48:31
Hi,

Here's a link to a snipt that has the two bits of code corrected for you: http://snipt.net/boydlee/ch-2-erowdata-properties

What we're doing is adding a custom property to the row object that matches the data we received from the JSON response (so row's "_title" property = item[i].title. This way when you are in the click event handler for the tableview, you can access the _title property of the Row itself (along with _description, etc).

Now you could just as easily create a property on your row object called "feedData" for example, and assign it the whole JSON node of: jsonObject.query.results.item[i]. Then in your click event you could access the whole data node by using:

selectedRow.feedData.title
selectedRow.feedData.description

and so on....



The example in the book is just simplified down a bit =)

Todd
Posts: 39
Comment
Ch 2 - e.rowData properties?
Reply #9 on : Thu January 12, 2012, 19:17:20
Here is a link to the code.
http://pastie.org/3175694

as noted this is
based on Chapter 2 - Recipe 7 - 3968_02_07-2.js

Thanks for the quick response earlier... I was away from my computer all day.

Boydlee
Posts: 39
Comment
RE: Ch 2 - e.rowData properties?
Reply #8 on : Thu January 12, 2012, 07:14:24
Could you please paste all your code into a pastie.org or snipt.net box and send me the link? That way I can duplicate it and will have a look for you.

Todd
Posts: 39
Comment
Ch 2 - e.rowData properties?
Reply #7 on : Thu January 12, 2012, 07:03:26
In chapter2 the section "Saving data locally using an SQLite database...
(the Kindle does not show a page number)

I have followed the recipes to this point and am using the RSS feed from (http://boydlee.com/feed.html) as a REST query from the YQL console. The table view loads and displays the 10 current items with title and description.

However the 'click' function for tblRecipes.addEventListener is not populating the properties through the e.rowData call.

When the var detailWindow is created, the properties title, _description, _link are not being populated. (they return undefined in Ti.API.info calls)

If I set each property to a string value, then the strings display correctly in the new window.

var selectedRow = e.rowData; //row index clicked
var detailWindow = Titanium.UI.createWindow({
title: 'selectedRow._title - string for testing',
_description: 'selectedRow._description - string for testing',
_link: 'selectedRow._link - string for testing',
backgroundColor: '#fff',
id: 0
});


Is e.rowData the correct way to address the tableRow data when loaded from a JSON feed? or is there an additional layer added to the rowData.?here?.

Ti.API.info(selectedRow.row); /// this returns the correct row number for the item selected from the tableView

However, I have not found a way to return the .title, description or index.

I have tried ....

Ti.API.info(selectedRow._title); /// this returns null
Ti.API.info(selectedRow.title); /// this returns null
Ti.API.info('title = ' + selectedRow.title); /// this returns 'title = undefined'
Ti.API.info('_title = ' + selectedRow._title); /// this returns '_title = undefined'

In the code you provide in the book... what is ._title referring back to in the following (is it a property of the row or a node in the RSS)?

var detailWindow = Titanium.UI.createWindow({
title: selectedRow._title,

Anonymous
Posts: 39
Comment
Re:
Reply #6 on : Fri January 06, 2012, 06:19:15
On page 25 of the book it references "win1" when it should be declared as "win2". Also the formatted has gone a bit screwy here, as the first line in the code block of page 25 should be:

//reference the current window
var win2 = Titanium.UI.currentWindow;

when it has instead been jammed onto one line as:

//reference the current window var win2 = Titanium.UI.currentWindow;


Here's revised code for Chapter 1 - http://boydlee.com/Chapter 1 Source Code - Revised.zip

Boydlee
Posts: 39
Comment
RE: Image Files?
Reply #5 on : Thu December 29, 2011, 04:48:15
Hi Bob,

Here's a link to the full source for the 1st chapter. You may be able to download the code from the publishers website again - Believe there was a file missing from the Chapter 1 source download from their site.

You can get it directly from here http://bit.ly/tIZjqy

Thanks

Bob Follek
Posts: 39
Comment
Image Files?
Reply #4 on : Thu December 29, 2011, 04:45:32
I don't see the image files (background.png, logo.png, etc.) in the code download. Are they available? Thanks.

admin
Posts: 3
Comment
The "className" property (Page 50)
Reply #3 on : Thu December 22, 2011, 05:58:39
A couple of people have asked me this now as I obviously didn't explain the "className" property of the TableView very well, so...

The "className" property is simply an identifier that helps the TableView keep a track of the row object to allocate and re-use when it is rendering the rows. This row object layout is stored in memory and identified by the 'className', and hence the layout doesn't need to be calculated for every row that is rendered.

As an example, if you created row A with a image and a label, then row B with no image, it can cause performance problems. It is a bit of a confusing property - if you come from an OO background you probably expect "className" references some other class somewhere in your application, however in this case, it's just an identifier.

admin
Posts: 3
Comment
Chapter 2 - RSS Feed Missing
Reply #2 on : Thu December 22, 2011, 05:40:16
The RSS feed published in the book for Chapter 2 is no longer available, however the code will work with any other standard RSS feed. Here's a couple you might like to try (note some of the XML Nodes may differ between feeds so this could be a good exercise in understanding this chapter better!).

http://news.yahoo.com/rss/internet

http://pipes.yahoo.com/pipes/pipe.run?_id=6d700ffd24a9b9d776bab0cd0205d1b5&_render=rss

http://boydlee.com/feed.html
Last Edit: December 22, 2011, 05:40:40 by admin

Bob Sims
Posts: 39
Comment
e.annotation.id
Reply #1 on : Tue December 20, 2011, 16:39:28
Boydlee,

Wonderful book! So nice to have a comprehensive reference that complements the TCAD-level course so nicely.

I think annotation eventlistener property on p87 code example should be http://e.annotation.id, not http://e.source.id?

Again, great work, I'm already incorporating lessons from it into a current project.

Bob


---

ANSWER:
Bob, you're totally right. It doesn't affect the running on the sample code, but it is incorrect. That line should read:

Ti.API.info('Annotation id that was tapped: ' + e.annotation.id);

Thanks,