-
18 Jan 2012 5:58 AM #1
NullPointerException in TimeField::getValue()::getDate()
NullPointerException in TimeField::getValue()::getDate()
Hello.
I've got the following issue(?) in 2.2.3:
Is it supposed behavior or I missed a step in initialization?Code:public class SomePanel extends ContentPanel { private final TimeField theFieldTimeStart = new TimeField(); private final DateTimeFormat theTimeFieldsDateFormat = DateTimeFormat.getFormat("HH:mm"); public SomePanel() { theFieldTimeStart.setTriggerAction(ComboBox.TriggerAction.ALL); theFieldTimeStart.setFormat(theTimeFieldsDateFormat); } @Override protected void onRender(Element aParent, int aPos) { super.onRender(aParent, aPos); final Time myTimeStart = new Time(); myTimeStart.setText("09:00"); theFieldTimeStart.setValue(myTimeStart); } private void handleSomeEvent() { //Here I need to get Date from theFieldTimeStart theFieldTimeStart.getValue().getDate(); //causes NPE theFieldTimeStart.getDateValue(); //causes NPE //my workaround: final Date myDateStart = theTimeFieldsDateFormat.parse(theFieldTimeStart.getValue().getText()); } }
Thanks.
-
18 Jan 2012 3:17 PM #2
Who is calling handleSomeEvent? The most important part is missing in your code snippet. Do you have a fully working testcase implementing EntryPoint? Why do you call setText to set the value? Have you tried to disable lazyrendering?
-
19 Jan 2012 12:44 AM #3
Hello, Sven.
1) Where thehandleSomeEvent
is called from:
Code:final Button myButtonAdd = new Button("Add");myButtonAdd.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { final SomeSelectionDialog mySomeSelectionDialog = new SomeSelectionDialog(); mySomeSelectionDialog.addListener(Events.Hide, new Listener<BaseEvent>() { @Override public void handleEvent(BaseEvent be) { handleSomeEvent(); ...
2) Unfortunately not, this is a part of a larger piece of code
3) Just tried to add to ctor theFieldTimeStart.setLazyRender(false) helped. Problem solved.
4) Just to make the picture full, here're the theFieldTimeStart with default LazyRender (note, that theFieldTimeStart.getValue() returns Time object with empty value, but getRawValue() contains proper string by the same time):
Attachment 30821
Thanks!


Reply With Quote