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
New Developer
david_schwartz_bb
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon
Accepted Solution

Refreshing a qnx List

I am displaying a qnx.ui.listClasses.List. When the user enters a new row on another form I want to refresh the list to show the new data. What is the recommended strategy? Thanks
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Refreshing a qnx List

Add the data object to the data provider.  That should refresh it automatically.

 

var mylist.dataProvider.addItem( { label : 'new item' } );

 

 

 

 

Please use plain text.
New Developer
david_schwartz_bb
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: Refreshing a qnx List

Perfect! Thanks.

I'm using your  Tweener.addTween method to show the detail form.

When user clicks save on detail form I want to update the list (on first form).

Is there a way to "wait" or update the first form?

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Refreshing a qnx List

You can do this one of 2 ways.

 

You can use the Flash Timer class to delay the execution of another function:

 

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/index.html?filter_flex=4.1&filter...

 

var delay : Timer = new Timer( 1000, 1 ); // wait 1 second (units=ms) for 1 time

delay.addEventListener( TimerEvent.TIMER_COMPLETE, Done );

delay.start();


....


private function Done( event : Event ) : void

{

  // do something now 

 

Or you can delay the start of the Tweener by:

Tweener.addTween( mycontrol, { delay: 2.0, ... } ); // in seconds

 

Please use plain text.
New Developer
david_schwartz_bb
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: Refreshing a qnx List

That delays the call but what if user is "sitting" on the detail page for a long time? How to show the updates/newe row?

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Refreshing a qnx List

I think I understand you are asking:

 

1) New entry in form

2) Update list

3) Close entry form

 

If that is correct, the update is very quick, so closing the form view at the same time the list has been asked to update is very quick.  If you are doing something else, you could update the list, add an event listener to when the data provider has updated, and then close or send a message to close the original form.

 

Am I getting warmer?

 

Please use plain text.
New Developer
david_schwartz_bb
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: Refreshing a qnx List

Getting hot!

I'm missing step 2) Update list.

 

List was on main form which was covered by new entry form & new entry form is seperate object.

How to call this on first form:

xData.addItem({ id : 999999, label : "Fermats last Theorem" });

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Refreshing a qnx List

In that case, you can do it in one of two ways:

 

1) Add item to the global data area, have it stored (if needed) and then send a message out that a new item has been added (or changed or deleted) and then all views that care about that data can refresh.  If the central store is a DataProvider, any view associated to that attribute would automatically update and the broadcast message would not be needed.

 

2) Have the editor send the data in a message out that this item is new.  This would require a custom event or use of the meta event class.  Then each view would perform the needed operation (update, store, etc.).

 

Pros and cons or each.  I am certain others have used other approaches as well.

 

Am I warmer now?

Please use plain text.
New Developer
david_schwartz_bb
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: Refreshing a qnx List

What do you think of this approach?

 

I create the detail page passing the list page object:

    notesDetailPage = new NotesDetailScreen(this);

 

Then I call the addItem method from the detail page:

    _parentObject.addItem("Fermats Last Theorem");

 

It works but I think its "dirty" since the detail page calls back to the list page.

Do you have any sample code for setting up central store as DataProvider?

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Refreshing a qnx List

[ Edited ]

I personally dont like passing views to other views to other views.  It get too tighly coupled and if you want to change or reuse a view later on, it is a total mess.

 

I personally use a global container (aka singleton) to pass events and hold state.  In this case, the DataProvider would be an attribute of the global/shared data container that might have other centralized data and functions to bridge many views of the application.  A singleton design pattern decouples views from one another and can pretty much not know about each other since the only thing they have in common is this shared bridge that can dispatch events and hold state.  There was another thread on this recently.  I will dig that thread up and edit this posting with it.  One moment please...

 

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Going-back-to-main-page/td-p/7124...

Please use plain text.