<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How can I circumvent NullPointerException in data bindings?</title><link>https://answers.axonivy.com/questions/438/how-can-i-circumvent-nullpointerexception-in-data-bindings</link><description>&lt;p&gt;I try to select an entry in a combo depending on a value in a record set like that: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;panel.comboCountry.selectedIndex 
    &amp;lt;- Integer.parseInt(in.EmployeeList.getField(in.RowId,"country").toString())-1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This works properly, but if &lt;code&gt;NULL&lt;/code&gt; is stored in the recordset, then Ivy throws a NullPointerException. &lt;/p&gt;
&lt;p&gt;How can I circumvent this?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/438/how-can-i-circumvent-nullpointerexception-in-data-bindings" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 18 Jan 2012 10:06:02 -0500</lastBuildDate><item><title>Answer by Martin Steiger</title><link>https://answers.axonivy.com/questions/438/how-can-i-circumvent-nullpointerexception-in-data-bindings/439</link><description>&lt;p&gt;Use the unary ? : operator on the right side of the data binding:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;in.EmployeeList.getField(in.RowId,"country") is initialized 
    ? Integer.parseInt(in.EmployeeList.getField(in.RowId,"country").toString())-1
    : null
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Steiger</dc:creator><pubDate>Wed, 18 Jan 2012 10:06:02 -0500</pubDate><guid>https://answers.axonivy.com/questions/438/how-can-i-circumvent-nullpointerexception-in-data-bindings/439</guid></item></channel></rss>