B4J Question xAnotherDatePicker (b4xlib) inside a xCustomListView - crash

LucaMs

Expert
Licensed User
xAnotherDatePicker (b4xlib 2.0) inside a xCustomListView (v. 1.73)

Simple test attached.

Waiting for debugger to connect...
Program started.
Error occurred on line: 58 (AnotherDatePicker)
java.lang.NullPointerException
at b4j.example.anotherdatepicker$ResumableSub_DesignerCreateView.resume(anotherdatepicker.java:737)
at b4j.example.anotherdatepicker._designercreateview(anotherdatepicker.java:683)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4j.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:62)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:93)
at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:84)
at b4j.example.main._createitem(main.java:131)
at b4j.example.main._appstart(main.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
at java.lang.Thread.run(Thread.java:748)
 

Attachments

Last edited:

LucaMs

Expert
Licensed User
I extrapolated the class (B4J and its layout) and used it directly; this way I could see exactly which line of b4j code generated the error
(note that the class inside the b4xlib I think is less recent than the one published here; even a great expert like me 😄 is getting lost with the versions of classes and libraries).

B4X:
Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
    mBase = Base
    Dim mlbl As B4XView = Lbl
#if B4J
    Dim form As Form = Props.Get("Form")
    MainPanel = form.RootPane
Props keys are:

customType
csType
shortType
HighlightedColor
MaxYear
MinYear
SelectedColor
type
BackgroundColor
FirstDay

then form variable will be Null.


So this view can only be used directly in a Form or Activity (Page b4i?), right?
 
Last edited:

Erel

Administrator
Staff member
Licensed User
Use the latest version of ADP, which is B4XDateTemplate from XUI Views. It is implemented as a dialog.

You can add a label and show the dialog when the label is clicked.
 

LucaMs

Expert
Licensed User
Ok, thank you, but... do you think "you" can change it to work that way too? Or should it be redone from scratch?
 

Erel

Administrator
Staff member
Licensed User
There is really no reason not to use the newer B4XDateTemplate. It is more powerful and will work in CLV without doing anything special.
 
Top