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
New Developer
saggy
Posts: 11
Registered: ‎03-25-2009
My Device: Not Specified
Accepted Solution

MainScreen.onDisplay() NullPointerException

I have a very simple app that is a MainScreen, with a HorizontalFieldManager, with some custom Fields added to it.  The app runs find and renders when I use the default style in the custom fields.  However, when I set FOCUSABLE style on the custom fields, the app throws a NullPointerException (I think on a null defaultFocus item) in the onDisplay method of my MainScreen (called as a direct result of UiApplication.pushScreen()).

 

I'm developing on JDE 4.2.1, Simulator 8800.  Anyone have any ideas to help diagnose and fix?

 

Thanks.

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: MainScreen.onDisplay() NullPointerException

If you follow the stack trace, are there any referecnes to your code?

Please use plain text.
New Developer
saggy
Posts: 11
Registered: ‎03-25-2009
My Device: Not Specified

Re: MainScreen.onDisplay() NullPointerException

Not after the initial call to UiApplication.pushScreen() ...

 

 

Screen.onDisplay() <-- boom Screen.callOnDisplay() UiEngineImpl.pushScreen( Screen ) UiApplication.pushScreen( Screen ) DBApp.DBApp() DBApp.main( String[] )

 

 

 

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: MainScreen.onDisplay() NullPointerException

did you read the Handling focus issues section in the field class?
overwrite these methods (and just call super) to see what happens there.
you can set the focusable style for a single field only to debug.
----------------------------------------------------------
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
Please use plain text.
New Developer
saggy
Posts: 11
Registered: ‎03-25-2009
My Device: Not Specified

Re: MainScreen.onDisplay() NullPointerException

I had read the Field docs, and gave your suggestion a try.  What I found was that isFocusable() on my custom fields was getting called.  But onFocus wasn't.  I had an onFocus() in the manager that contained the fields, though.  I took a look at that and noticed it only had a log message in it.  For some reason, I had neglected to make the call to super.onFocus().  And that was the problem.  When I added that back in (and actually, removed the override at the manager level all-together), the exception went away and all things began working again.

 

Thanks for the help.

Please use plain text.
Regular Contributor
lyhoanghai
Posts: 71
Registered: ‎03-24-2010
My Device: 9550
My Carrier: Vodaphone

Re: MainScreen.onDisplay() NullPointerException

I have the similar symptom:

NullPointerException within onDisplay().

This error is quite annoy because we have to clue to find out the error.

 

In my case, the cause of this exception is different. I post here and hope that it is helpful for other people:

 

- I have a Manager object without any "focusable" field in side.

- I override Manager.isSelectable()

 

Solution:

- Add a NullField to the Manager.

 

 

Please use plain text.