Note that I’m passing a reference to the table in the 1st property so I can update the item later on. The table shows up fine, however, the reference to it is always null. The debug statement will always show null and so will later accesses. Yet the addItem part works fine. I tried to use the attach() method with the same result. What am I missing?
You are not logging the reference to the table, but the value of toString(), which in your case is probably the value of the table (the itemId of the selected row) - in your case ‘null’ because nothing is selected.
Never trust toString() to return the object id - it can return anything.
thank you for your reply. It may be true regarding the toString() in this particular case. However, my problem is that when I try to access that table reference later on in order to update some data it throws a null pointer exception.
in other words, changing the log statement to
logger.debug("tabletoUpdate " + tabletoUpdate + " tabletoUpdate==null?yes:no = " + (tabletoUpdate==null?“yes”:“no”));
returns a “yes” so it looks like a true null.
Well, you can not possibly call
extUserTable.addItem() without causing a NPE if
extUserTable==null , so in that case there is something missing from your description of the situation. I’m afraid I can not help without a more complete example then - except saying that if the ‘reference’ is non-null at this point, and null later on, then just don’t set it to null in between