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
Trusted Contributor
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
My Carrier: Digicel

Linking a Table Cell and a display area...Brain Storming

Hello again

 

 

I am not asking for code in particualr(I won't say no though)

 

Just imagine this. I have a table that takes up half the screen. And a display area underneath the table taking up the rest of the screen. Now what I want to do is display more data on that particular cell in this display area. And when a different cell receives focus, the information below the table changes to correspond with the cell. So basically each cell has it's individual information to be displayed. What I want to know is how do I save that information(it's going to be a lot of information) and make it individual to the cell and then how do I update that Display area when another field receives focus. Any ideas? please?

_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Highlighted
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Linking a Table Cell and a display area...Brain Storming

You have some fields in those cells, don't you?

To associate any Object with a Field, use setCookie. To retrieve it, use getCookie.

 

To track the focus changes, use FocusChangeListener.

 

To modify some area of the screen, you can replace fields in there or simply change the contents of the fields: setText for all kinds of text fields, label fields, etc., setBitmap for BitmapFields - you get the idea.

 

Good luck!

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
My Carrier: Digicel

Re: Linking a Table Cell and a display area...Brain Storming

Yes sir, thank you. I was thinking on those lines. You mentioned setCookie for associating an Object with a field, I'll look into that. Is there however, a way to store information and associate it with,say, and Individual cell of a table.?
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Linking a Table Cell and a display area...Brain Storming

Just create an array or a Vector of Objects you want to associate with those cells. When the focus moves within the table (by the way - what are you using for a table? GridFieldManager? TableLayoutManager?), check what cell has focus and find the corresponding item in the array/Vector.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
My Carrier: Digicel

Re: Linking a Table Cell and a display area...Brain Storming

Ok, now here is the real issue. I want this to occur.

I have a table with different cells, each cell has a large amount of related information of different data types, and I want the data to be Persistable as well. Any suggestions?

What I thought would be a good idea, was to create a class that implements Persistable, then create a Vector of Objects- with each Object having the various bits of information to be saved-that would be inside that Persistable Object.

Do you think that is a good idea or is there a better way?
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Linking a Table Cell and a display area...Brain Storming

Looks OK to me, but other people might have other opinions. You can serialize the objects (into XML or something similar) and save them on the file system instead - your choice.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
My Carrier: Digicel

Re: Linking a Table Cell and a display area...Brain Storming

I have an issue though with Persistent Storage. It seems that I can't make new methods in Objects. So I created a class that extends Object and put my own methods in it. I would then make a Vector of my Object. The Vector would then be placed in my Persistable Object. The only problem is that the class I am using must implement Persistable as well. But when I am getting the contents of the Persistable Vector, I need to accept the data into a similar Object. But i can't because the Object implemented Persistable. Are there any methods I can use to get around this?
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Linking a Table Cell and a display area...Brain Storming

Sorry I don't understand the question.

 

There is nothing stopping you adding methods to a Persistent Object.  That works fine.  

 

A Vector is Persistable, and so you can add your persistable objects to a Vector or add a Vector to your perishable Object, that will work fine. 

 

Can you explain your problem again?  Perhaps a small code sample will help?  Please make it small and representative rather than your entire class. 

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Linking a Table Cell and a display area...Brain Storming

If I understand you correctly, the way I handle this for some applications is to have three classes:
1) There is the class that implements persistable that is package private
2) There is a settings class that is used to interact with the persistable objects
3) There is an internal public class to the settings that cannot be instantiated and returns data matching what is in the persistable so that you are not directly manipulating data
As long as you are using primitive values or classes/objects that only contain primitive values then you don't have to worry about it not being persistable
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Linking a Table Cell and a display area...Brain Storming

That is unfortunately not what I meant.

 

You can have a Settings class that implements Persistable.  it can have primitives in it.  If it has any Objects in it, these must also implement Persistable.  If it has any collections then the Collections should also be Persistable (I believe most are, certainly Vector and Hashtable which are the ones I use are Persistable).  And any Objects that are added to a Collection that is part of a Persistable Object, must also be Persistable. 

 

In addition, this Settings class can have any methods that you want.

 

There is not need to have a Wrapper Object, though to be honest, I usually do, to abstract the storage mechanism from the users of the data.  As an example, say my Wrapper class is called Repository, then users will interact like this

String userName = Repository.getUserName()

Repository.setUserName( newUserName);

 

The Wrapper Object actually manages both PersistentStore and RuntimeStore, so that the user does not know where the user name string came from, nor do they care how it was actually stored. 

 

Specific answers to your quests are:

1.  May be private, may not be.  Depends on how you want tot do it.  For me it is usually private.

2.  Can be, if you want to abstract your interface to persistent objects.  I typically do and I typically call this class Repository. 

3.  Depends on your implementation, but the answer is typically yes from me.