How to determine what is visible the last row in the table container to load the more data? This is required for lazy data loading via EJB. Thanks.


You can try utilizing the sum of Table#getCurrentPageFirstItemIndex() + Table#getPageLength() methods in order to determine the last item, though I would suggest implementing such kind of logic in the container somehow, so the overall Table behavior would be more natural.


I have no idea how you implemented the table datasource but i think you could have a look on the thread in case 1:

You want to have a pagedTable with lazy loading entities:

this container will know the pageSize and the displayed page.

startIndex = page*pageSize;
endIndex= (page+1)*pageSize-1;

Case 2:

If you want to lazily load the items from DB into a scroolable table (not paged) then you could implement a table container that implements interface.

static interface Ordered extends {

    java.lang.Object nextItemId(java.lang.Object o);
    java.lang.Object prevItemId(java.lang.Object o);
    java.lang.Object firstItemId();
    java.lang.Object lastItemId();
    boolean isFirstId(java.lang.Object o);
    boolean isLastId(java.lang.Object o);
    java.lang.Object addItemAfter(java.lang.Object o) throws java.lang.UnsupportedOperationException; addItemAfter(java.lang.Object o, java.lang.Object o1) throws java.lang.UnsupportedOperationException;

Case 3:

If you just want to know the firstId and the lastId of the displayed resultSet then you just call this: table.getVisibleItemIds() and then the first element is firstId and respectively the last one is the visible lastId.

personally I choose case 2 for implementing a table container that lazily loads data from a service. this service must implement an interface like that:

public interface DataService{
List find(Integer startIndex, Integer endIndex, String orderField, int order, Condition… condition);

Number count(Condition... conditions);

Object findById(Serializable baseRecordId);


this service could take data from databases, xml , webservices… etc… the only requirement is to respect that interface.
(for now i’m focused on hibernate entities and DTO objects that takes data from joins between multiple tables.)

Thank to all for advice. I have one more question. How to determine what the user uses the scroll in the table? Listener, who would be responsible for this, I have not found :frowning:

I would try to use
to create a container that loads actual data via EJB. Haven’t used LQC myself but I have heard that it would fit for your needs great :wink: