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
Highlighted
Contributor
Posts: 16
Registered: ‎07-28-2010
My Device: Bold 9700
My Carrier: Vodafone
Accepted Solution

PersistentObject and SendListener Problem

I have registered a SendListener to intercept outbound emails. When my handler is called I would like to access my application settings stored in PersistentObject to determine what I should be doing in my sendMessage Handler. 

 

The problem is I can't access any information set in my application. I suspect this is because my sendMessage Handler is running in the context of the mail application. 

 

What design do I need to follow to access my persistent store from a handler like this?

 

Thanks

John.

 

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

Re: PersistentObject and SendListener Problem

I must admit I have not actually tested this recently myself, but AFAIK you should be able to access your Persistent Objects - assuming your are running using your own code and Persistent Object classes, the context should not matter.

 

Can you describe the issue when you attempt to access the information?  If your objects seem to be 'null' then I would suspect you are using static references.  static variables are specific to a context, so your listener will see different static variables to your application.

 

The reason I have not tested this recently is that normal practice for listeners is to context switch to your own Application, and the usual way to do this is via a GlobalEvent

http://supportforums.blackberry.com/t5/Java-Development/Global-Events-and-Global-Event-Listeners/ta-...

 

Contributor
Posts: 16
Registered: ‎07-28-2010
My Device: Bold 9700
My Carrier: Vodafone

Re: PersistentObject and SendListener Problem

Thanks Peter,

 

My application wraps its settings in a class, the settings are stored inside a Hash table defined as follows:

 

static Hashtable settingsTable;

 

You suspect the static declaration is the problem? 

 

I'd not considered the context switch - I will investigate that too. 

 

// John Goodyear
Developer
Posts: 16,984
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: PersistentObject and SendListener Problem

static variables are not shared between contexts, maybe that is related to your issue.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 16
Registered: ‎07-28-2010
My Device: Bold 9700
My Carrier: Vodafone

Re: PersistentObject and SendListener Problem

Removing static has fixed the problem - thanks for your quick replies and solution everyone. 

// John Goodyear