Table Reference Null even though can add items

I have a table on the screen and doing this to populate it.

logger.debug("extUserTable = " + extUserTable);
[b]

extUserTable
[/b].addItem(new Object { ActionLayout.buildActionLayout(ub.getLoginId(), appContextHelper,
extUserTable
, false, false),
ub.getFname(),
ub.getLname(),
ub.getStatus(),
ub.getIrevRoleDesc(),
ub.getLoginId(),
ub.getEmailAddress()}, ub.getLoginId());

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?

Thank you for your help

Hi,

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.

Best Regards,
Marc

Mark,

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.

Thanks

Hi,

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 :wink:

// Marc

Mark, as silly as it sounds you were right. I was not initializing a parameter in the constructor.
Thanks for your help!