Problem with Auto Complete TextField

62 views
Skip to first unread message

mikko.nu...@gmail.com

unread,
Oct 29, 2014, 10:44:31 AM10/29/14
to codenameone...@googlegroups.com
Hi,

I'm having trouble with AutoCompleteTextField, it seems to cause NullPointer in real device (Samsung / Android, iPhone 5 / iOS) when initial text is set to it (.setText("foo")) and while it is added to a container. Again this works fine with simulator. In my case I'm trying to fill the component with contact emails from phone memory. The text that I want to initially set is also some persons email but that is not necessarily from the that phones memory. Ok, that "might" have been understandable that setting the text that is not in the list (String[]) of AutoCompleteTextField causes someting like this, but I also tried to add the initial value to that list and that didn't work. The software does not render any other components when method below is called (another methods alike [creating different components] are not called any more). This works fine if I comment the setText(text) away from the code but it is problem because user does not know which value it is editing.



java.lang.NullPointerException
	at com.codename1.l.a.a(AutoCompleteTextField.java:132)
	at com.codename1.l.a.b(AutoCompleteTextField.java:114)
	at fi.descom.compassmobile.e.b.b.a(Unknown Source)
	at fi.descom.compassmobile.e.b.b.a(Unknown Source)
	at fi.descom.compassmobile.d.f.b(Unknown Source)
	at fi.descom.compassmobile.d.f.a(Unknown Source)
	at fi.descom.compassmobile.d.f$2.a(Unknown Source)
	at com.codename1.l.j.c.a(EventDispatcher.java:323)
	at com.codename1.l.b.a(Button.java:393)
	at com.codename1.l.b.b(Button.java:424)
	at com.codename1.l.b.d(Button.java:512)
	at com.codename1.l.o.d(Form.java:2373)
	at com.codename1.l.o.d(Form.java:2309)
	at com.codename1.l.h.f(Component.java:2607)
	at com.codename1.l.l.m(Display.java:1913)
	at com.codename1.l.l.j(Display.java:1009)
	at com.codename1.l.l.i(Display.java:940)
	at com.codename1.l.z.run(RunnableWrapper.java:120)
	at com.codename1.impl.b$1.run(CodenameOneThread.java:60)
	at java.lang.Thread.run(Thread.java:856)

mikko.nu...@gmail.com

unread,
Oct 29, 2014, 10:52:24 AM10/29/14
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
 public static void createAutoCompleteWithHeader(String header, Container container, String text, String variable,
        String[] items, int constraint) {

        HeaderLabel headerLabel = new HeaderLabel();
        headerLabel.setText(header);
        headerLabel.setName("header");

        AutoCompleteTextField autoCompleteTextField = new AutoCompleteTextField(items);
        autoCompleteTextField.setText(text);
        autoCompleteTextField.setLabelForComponent(headerLabel);
        autoCompleteTextField.setConstraint(constraint);

        container.addComponent(headerLabel);
        container.addComponent(autoCompleteTextField);
    }

Shai Almog

unread,
Oct 29, 2014, 9:29:32 PM10/29/14
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
Thanks.
This is probably related to a fix made to a different issue, we'll fix the exception.

mikko.nu...@gmail.com

unread,
Oct 30, 2014, 11:46:39 AM10/30/14
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
Hello,

no problem, glad that is a clear case. How do we know when the component is usable again?

Mario Barón

unread,
Dec 3, 2014, 2:08:19 PM12/3/14
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
Hey guys,

I am getting a similar error: NullpointerException when I click on the AutocompleteTeextfield component this is the error:

java.lang.NullPointerException
at com.codename1.ui.AutoCompleteTextField.addPopup(AutoCompleteTextField.java:273)
at com.codename1.ui.AutoCompleteTextField.access$300(AutoCompleteTextField.java:39)
at com.codename1.ui.AutoCompleteTextField$FormPointerListener.actionPerformed(AutoCompleteTextField.java:332)
at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:323)
at com.codename1.ui.Form.pointerReleased(Form.java:2328)
at com.codename1.ui.Component.pointerReleased(Component.java:2607)
at com.codename1.ui.Display.handleEvent(Display.java:1913)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1009)
at com.codename1.ui.Display.mainEDTLoop(Display.java:940)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)


On this exact line in bold of the following block in theAutoCompleteTextField.class:

popup.addComponent(l);
        popup.getStyle().setMargin(LEFT, getAbsoluteX());
        byte [] units = popup.getStyle().getMarginUnit();
        units[Component.LEFT] = Style.UNIT_TYPE_PIXELS;
        popup.getStyle().setMarginUnit(units);


Mario Barón

unread,
Dec 3, 2014, 2:09:25 PM12/3/14
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
oopss sorry forgot to mention, this is only happening on the simulator, not on normal devices, or at least the ones I've used.


On Wednesday, October 29, 2014 9:44:31 AM UTC-5, mikko.nu...@gmail.com wrote:

Shai Almog

unread,
Dec 4, 2014, 1:50:16 AM12/4/14
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
There was a regression in the latest release that we since fixed on the build servers.
It will be fixed in the next library update.
Reply all
Reply to author
Forward
0 new messages