java - Vaadin CheckBox object becomes null -
i have vaadin object:
checkbox mycb = new checkbox("caption");
later on value of checkbox updated database this:
mycb.setvalue(dbvalue);
dbvalue
null in database. mycb
not null before line, , null after line. shouldn't value remain same, mycb.getvalue()
returning null?
furthermore, trying avoid nullpointerexception short-circuit evaluation:
if (mycb != null && mycb.getvalue() == true) ...
that produces nullpointerexception anyway. normal behavior or there i'm doing wrong?
you said mycb doesn't become null. that's great.
if (mycb != null && mycb.getvalue() == true)
this throws nullpointerexception
because java tries cast result of mycb.getvalue()
boolean
. because mycb.getvalue()
returns null
, throws nullpointerexception
.
change to:
if (mycb.getvalue() != null && mycb.getvalue() == true)
or similar
Comments
Post a Comment