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

Web and WebWorks Development

Reply
Regular Contributor
tububerry
Posts: 51
Registered: ‎05-25-2012
My Device: Bold 9930
Accepted Solution

Application not working for the first time, but works fine when I close & reopen

This problem might sound very strange.

 

I have written webworks app. which writes data to persistent store and retrieves it back.

 

The problem is that.I install the app and  When I click the 'getFromStorage' button(in index.html) it successfully calls it extension. but nothing happens in the first execution. I mean invoke is not called, hence no subsequent methods are called.

 

But when i close the app & reopen & click on 'getFromStorage' button(in index.html) it successfuly stores & retrives the data. so i mean to say,, the app is working fine in the subsequent execusions.

 

I have set EventLogger to see what is hapennning,  I see that the constructor 'DataFactory' is called followed by 

System data:VM:NPOEr=0x232B1800,t=webworks.storage.persistence.MyObject (this is my Object type, but not actual object,  I want to save to memory)

 

Below is the gist how I am implementing it. 

 

invoke(....){

...

DataFactory() _myObj  = new DataFactory();

_myObj.getFromStorage();// This calls 

...

}

 

 

//Separate class

class DataFactory{

static Vector _data = new Vector();

 

DataFactory(){

some values are set to _data

synchronized(_store)
{
 _store.setContents(_data);
_store.commit();

}

getFromStorage(){

Vector _vectorStore = (Vector) _store.getContents();

}

}

 

 

Any clue, what is going wrong and where?

 

 

 

 

 

 

 

Regular Contributor
tububerry
Posts: 51
Registered: ‎05-25-2012
My Device: Bold 9930

Re: Application not working for the first time, but works fine when I close & reopen

I found the problem.

 

I was trying to store the Vector() object. But the contents of the Vector were not implemented by Persistable Interface.

Hence it was throwing NonPersistableObjectException.

 

So I implemented Persistable  on  the class (whose objects I was storing).

Now its working fine.