NPE because of null RowSelect when exporting

1 view
Skip to first unread message

Denny

unread,
Jul 28, 2008, 12:45:07 PM7/28/08
to JMesa
Group -

This might be a bug or it may be the result of how I'm using JMesa.
Either way, I think it is a good idea to make the group aware of it so
that it is at least documented.

I'm building a table using the tag library. In order to export, my
controller defines a similar table using the TableFacade and then
calls render. When ItemsImpl gets constructed, it calls
getPageItems. The limit passed in has a null RowSelect, so I get an
NPE when it hits limit.getRowSelect().getRowStart();.

To get around this, I'm new'ing a RowSelectImpl and explicitly placing
it on the Limit of the TableFacade.

Here is the snippet of code that handles the export:

<snip>
TableFacade tableFacade = new TableFacadeImpl(id,
context.getRequest());
if (tableFacade.getLimit().isExported()) {
tableFacade.setExportTypes(context.getResponse(),
ExportType.CSV, ExportType.EXCEL, ExportType.PDF);
tableFacade.setColumnProperties("collapsed", "value.id",
"value.user.loginId", "value.status",
"value.createTime", "value.expirationTime",
"value.endTime", "value.remoteAddress",
"value.clientVersion", "value.user.fullName");
tableFacade.setItems(values);
tableFacade.getLimit().setRowSelect(new RowSelectImpl(1,
10000, rowcount));
tableFacade.render();
return null;
}
</snip>

Should I be constructing a RowSelect object or should this be handled
for me by a step I'm missing in the above snippet?

Thanks,
-Denny

Jeff Johnston

unread,
Jul 28, 2008, 1:08:15 PM7/28/08
to jm...@googlegroups.com
No, you should not have to construct a RowSelect object. That is also really straightforward code...

Do you have a stack trace? Also what version of JMesa are you using?

-Jeff Johnston

Jeff Johnston

unread,
Jul 28, 2008, 1:27:31 PM7/28/08
to jm...@googlegroups.com
I see it now....

You need to set your items on the facade before asking any questions on the Limit object. I will put some checks in for this condition.


TableFacade tableFacade = new TableFacadeImpl(id, context.getRequest());
tableFacade.setItems(values);

 if (tableFacade.getLimit().isExported())  {

}

The reason is because various parts of the underlying building of the table are pulled at runtime so that you can customize things as desired. For the most part you do not need to worry about the order of things. In the places you do the API does extensive checking to make sure it is obvious on what to do. I will add this to the list.

-Jeff

Denny

unread,
Jul 28, 2008, 1:53:22 PM7/28/08
to JMesa
Jeff,

Thank you very much! I'll move that line around. Appreciate the
quick response!

Thanks,
-Denny

Reply all
Reply to author
Forward
0 new messages