I have a popup calendar on my window that gets the date from an entry in the dataset that a user selects. The problem is that sometimes this value starts off as Null from the database.
I have the date field bound to this expression:
if(len({Root Container.CurrentRecord}) > 0,toDate({Root Container.CurrentRecord}[0,"ResponseDate"]),toDate('1900-01-01 00:00:00'))
So, when I run the project, if the dataset record has Null in the ResponseDate field, then the popup date box display is blank, the property editor shows the date field as . and when I click on the date box to enter something get the following error:
java.lang.NullPointerException
at java.util.Calendar.setTime(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)
at com.inductiveautomation.factorypmi.application.components.PMIDateTimeSelector.setDate(PMIDateTimeSelector.java:156)
at com.inductiveautomation.factorypmi.application.components.PMIDateTimeSelector.setLatchedDate(PMIDateTimeSelector.java:169)
at com.inductiveautomation.factorypmi.application.components.PMIDateTimePopupSelector.initSelector(PMIDateTimePopupSelector.java:144)
at com.inductiveautomation.factorypmi.application.components.PMIDateTimePopupSelector.actionPerformed(PMIDateTimePopupSelector.java:158)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)