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

Java Development

Reply
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
Accepted Solution

Problem with Persistable

I am struggling a bit with data binding. I receive the data in XML-format. I store it in objects for later use.  These objects are made Persistable since I want to store them in a hashtable which in turn is stored in persistent storage.

 

The application is made up of separate projects so definitions of these objects (classes) are  shared between the  projects via linked source like many other classes. Basically its a background project containing Listeners and some action modules and a GUI project with business logic. This split has worked fine uptil now.

 

The problem I have run into seems to emanate from having the classes that define the data linked and made "Persistable"

 

These linked classes that implements "Persistable" causes an error message when the second project is started

in the simulator.

 

Error Starting MobismaLogHandler  Class 'bbcommon.BBConstants' multiply defined

 

Or is it some other problem??

 

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
Developer
CMY
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook

Re: Problem with Persistable

Are the persistable classes defines in a separate library project or are they included in each application. The first will work, the second will not unless you change the name/package in each subsequent application that uses the classes.
Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Problem with Persistable

CMY.

Thanks for replying

I can reduce the description of the setup to 3 Eclipse projects.

1. Background engine. Listeners and action threads.

2. Gui and business logic.

3. Common classes.

 

The common classes are linked vith standard  "Link source" methods, not a library. It will result in the same

package name in the other 2 projects. Otherwise it would not compile correctly.

 

Do I understand you correctly that if a class that is going to be shared between 2 projects and is implementing "Persistable" thn it has to be in a library?

 

I did use a libray to share code between projects in the previous relese of the app but changed to linked source since it seemed simpler.

 

Your suggestion of changing the package name defeats the whole idea of  having a shared common source would it not?

 

 

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
Hithredin
Posts: 404
Registered: ‎06-03-2010
My Device: Z10 Red

Re: Problem with Persistable

I had problems with persistables class from a library used by 2 projects.

to be certain it'll work, indeed use different packages for each project. I do not see a different option.
use a build script, i haven't followed ant for blackberry since a year but it could be useful for you
Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Problem with Persistable

hmm.

Thanks

 

Have started out trying a libray. Will test that first. 

Ant is a new stumble stone to learn

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem with Persistable

[ Edited ]

"Do I understand you correctly that if a class that is going to be shared between 2 projects and is implementing "Persistable" then it has to be in a library?"

 

Pretty much.  To be 100% accurate, there can only be one 'definition' of a persisted class on the BlackBerry.  The easiest way to achieve this is to have the Persisted classes defined in a Library and have applications sharing that Library. 

 

"I did use a library to share code between projects in the previous release of the app but changed to linked source since it seemed simpler."

 

I think it is simpler too, and it saves issues with packaging too since you know each 'application' is complete. But this issue is the result. 

 

"Your suggestion of changing the package name defeats the whole idea of  having a shared common source would it not?"

 

Yes - because then each 'application' would not be able to read data stored by the other application. 

 

Now, I am not sure I have enough information to make a recommendation to you with 100% confidence, but I think you have two options:

 

a) create a Library, and import that Library on the Build path of the projects that use this.  Then you will ship cods for each of the projects and for the Library.

 

b) merge everything into one project. 

 

There is a another perhaps less palatable option, and that is to make all the Persistable Objects standard Rim objects.  For example, you could store all your Objects as Strings in XML format, and convert them to Objects by parsing them as part of the retrieval from Persistent Store.  So your application program still gets an Object, but the data that is persisted is the XML String.  But, in addition to the fact that this involves converting Objects to and from standard RIM Java classes, it also means that the Persisted data will not be removed from the device when your app is deleted. 

 

Hope this makes sense. 

Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Problem with Persistable

Thanks all

 

And Peter,

 

I think taht sums it up pretty good. I am going for the Library solution.

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
Hithredin
Posts: 404
Registered: ‎06-03-2010
My Device: Z10 Red

Re: Problem with Persistable

Take care if you use the library of how you want to deploy it.
With a BES it's ok, but i do not know if it is possible to deploy an application with a shared library to appworld.
Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem with Persistable

[ Edited ]

This should not be a problem.  You can package as many cods as you like with an application to App World.  Some applications I put on App World are multiple projects and I just add all the appropriate cods to the App World deployment. 

Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Problem with Persistable

Good.

 

Changing to a library solved my problem

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.