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
Posts: 384
Registered: ‎08-12-2008
My Device: 8700
Accepted Solution

SimpleSortingVector extended from Vector, but it is not Persistable

Hi All,

 

I have created SimpleSortingVector Object and want to save  to persiststore, but it will always throws me on-persistable object,

 

if I extends SimpleSortingVcetor and implements Persisable, it will give me building error such as:

 

marked Persistable by interface: net.rim.device.api.util.Persistable is not Persistable: base Class net.rim.device.api.util.SimpleSortingVector does not implement net.rim.vm.Persistable

 

why this class extended from Vector, vector can be saved, while SimpleSortingVector can not.

 

Is there any trick to play with this issue?

 

Thanks.

 

Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: SimpleSortingVector extended from Vector, but it is not Persistable

The objects which you are trying to store in persistent (thru vector) should  extend Persistable

 


Press the kudos button to thank the user who helped you.

If your problem was get solved then please mark the thread as "Accepted solution".

 

 

Deepesh Gupta
Developer
Posts: 384
Registered: ‎08-12-2008
My Device: 8700

Re: SimpleSortingVector extended from Vector, but it is not Persistable

Thanks,

 

what I means is that SimpleSortingVector can not commit to Persistore.

 

Here is my SourceCode:

 

ssv = new SimpleSortingVector(); ssv.setSortComparator(new Comparator(){ public int compare(Object o1, Object o2) { String s1 =(String)o1; String s2 =(String)o2; return s1.toLowerCase().compareTo(s2.toLowerCase()); } public boolean equals(Object obj) { return false; } }); ssv.setSort(true); indexs = new Hashtable(); content.put(KEY_WORD_LIST,ssv); content.put(ID_LIST,indexs); synchronized(persist){ persist.setContents(content); persist.commit(); } //content is hashtable //and the error happens on this line // content.put(KEY_WORD_LIST,ssv); // I have not added any object to SimpleSorting Vector.

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: SimpleSortingVector extended from Vector, but it is not Persistable

I presume Deepesh means implements Persistable, rather than extends Persistable.

 

Can we see the source for your SimpleSortingVector, at least the beginning of it including the constructor and any 'local' variables that are declared.  Don't need to see any methods.

Developer
Posts: 384
Registered: ‎08-12-2008
My Device: 8700

Re: SimpleSortingVector extended from Vector, but it is not Persistable

Thanks, Peter,

 

Here is the class that I want to customized by myself:

 

private class PersistableSimpleSortingVector extends SimpleSortingVector implements Persistable { public PersistableSimpleSortingVector() { super(); } }

 

 

if I implemented this line, when I do a building, it will gives me building error says:

 

PersistableSimpleSortingVector marked Persistable by interface: net.rim.device.api.util.Persistable is not Persistable: base Class net.rim.device.api.util.SimpleSortingVector does not implement net.rim.vm.Persistable

 

Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: SimpleSortingVector extended from Vector, but it is not Persistable

The objects which you are going to add in SimpleSortingVector should extend Persistable. Every object that can persist between handheld resets must implement persistable.See the description of persistable class for more guidance.

 

 


Press the kudos button to thank the user who helped you.

If your problem was get solved then please mark the thread as "Accepted solution".

Deepesh Gupta
Developer
Posts: 384
Registered: ‎08-12-2008
My Device: 8700

Re: SimpleSortingVector extended from Vector, but it is not Persistable

Thanks,

 

I known if I want to added object to persistable store, I should implement from Persistable.

 

My problem is:

 

I just create a new SimpleSortingVector(), and put it into Hashtable and do commit,

 

at that point, there is no Object is added to SimpleSortingVector().

 

Because the error says: SimpleSortingVector is no Persistable Object.

 

I will create a simple source code to post here.

 

By the way,my JDE is 4.2.1

 

Regards

 

 

Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: SimpleSortingVector extended from Vector, but it is not Persistable

You must adding some object in SimpleSortingVector. That object should implements Persistable

 

 

 


Press the kudos button to thank the user who helped you.

If your problem was get solved then please mark the thread as "Accepted solution".

Deepesh Gupta
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: SimpleSortingVector extended from Vector, but it is not Persistable

I understand now.  I thought you were creating your own SimpleSortingVector.

 

SimpleSortingVector does NOT implement Persistable.  As such, you can not extend it, and create a Persistable Object.

 

If you require SimpleSortingVector functionality in a persistable object, you are going to have to extend Vector and add that functionality yourself.

Developer
Posts: 384
Registered: ‎08-12-2008
My Device: 8700

Re: SimpleSortingVector extended from Vector, but it is not Persistable

Thanks Peter,

 

The thing is SimpleSortingVector is Object, we can simple extend from Object and implements Persistable, It will be persistable,

 

Why does not allow to extend from SimpleSortingVector and implements Persistable?