Skip to main content

Use BlackBerry DateField with PeerComponent raises various errors

1 reply [Last post]
ajochems
Offline
Joined: 2010-08-23
Points: 0

I try to add a BlackBerry DateField to a form defining it as a PeerComponent but i can not get it to work. In the form i use the code

DateField nativeBBDateField = new DateField("", inputDate.getTime(),DateField.DATE);
PeerComponent peer = PeerComponent.create(nativeBBDateField);

form.addComponent(peer);

When i run this i get the error:

IllegalStateException: UI engine accessed without holding the event lock.

If i then change the createNativePeer method in BlackBerryImplementation to the code below this error disappears but then i get a NullPointerException:

if (nullFld == null) {
nullFld = new NullField();
nullFld.setFocusListener(new FocusChangeListener() {
public void focusChanged(Field field, int eventType) {
if(lightweightEdit != null) {
finishEdit(false);
}
}
});
synchronized(UiApplication.getEventLock()) {
try {
canvas.add(nullFld);
} catch(Throwable t) {
t.printStackTrace();
}
}
}
How can i use the native Blackberry DateField component on a lwuit form?
Kind Regards,
Andre

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

Thanks, that seems like a good fix. If you have a stack trace to go with the null pointer exception that would help us narrow down the problem. Feel free to open an issue on the matter.