I suggest you ...

Create a container that can load lazily from sources

With huge datasets it is not good to load everything into the jvm at once. We need a container that can load lazily from various sources. I suggest that the container should take in an interface implementation telling it how to get more entries and telling it the size of the whole data set. getObjectById, sorting possibilities, filters etc would also be nice.

217 votes
Sign in
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Jens Jansson shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


    Sign in
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      • Noisy Boy commented  ·   ·  Flag as inappropriate

        I was trying like this
        public void addCustomListener2(ILazyLoadingComboboxCallBack callBack, ValueChangeListener sheetChangedListener) {
        this.addFocusListener(event -> {
        if (!loaded) {
        try {
        List<String> dataList = callBack.loadComboBox();
        Object selectedValue = this.getValue();
        if (selectedValue != null && !dataList.contains(selectedValue)) {

        loaded = true;
        } catch (Exception e) {
        LOGGER.debug("Exception while loading lazy combobox {}", e);

        It worked for me. I was showing the icon of loading inside combobox.
        Call can be converted to asynchronous.

      • Guillermo commented  ·   ·  Flag as inappropriate

        I suppose Jens is talking about tables, since they are the only ones that can handle huge number of elements.

        As far as I know, they already do handle lazy loading. At least they do in my app. The problem in my case is that Hibernate is not able to handle huge number of elements without becoming incredibly slow. Even when twiked to perform lazy loading, the programming model changes so much that I desperately need Java 8 for having closures (aka lambdas) so that executions (functions) can be applied lazily.

        By the way I think that doing what Jens suggests is not that hard. Simply implement an interface LazyLoad that has 3 methods ( + one utilility method that could be implemented with a trait) :

        int numberOfItems() // returns the size of the full collection
        int numberOfItemsPerPage() // returns the size to be loaded at once
        void load(int begin, int end) // loads only those items in memory
        void load(int begin) { load( begin, begin + numberOfItemsPerPage() ); }

        And then it is already done.

        You only need the Table object to understand that protocol and load elements on demand.

      • walid commented  ·   ·  Flag as inappropriate

        Ideally a container to do the fetch array, As the context is saved, the database query not fetched for all rows, but when the user scroll in the table, and the table need to fetch next rows from the app server, this event can be catched and the query rows fetched,

      • livotov commented  ·   ·  Flag as inappropriate

        SO probably we just need to rework the container interface to make it simplier for understanding and implementation for every particular need by the developer ?

      • Joonas Lehtinen commented  ·   ·  Flag as inappropriate

        Designing an abstract lazy container that suits everyones needs is a tricky business. In theory Container interface itself is the thing you are requesting, but in practice it would be great if one would be have to implement all the methods. The crucial question is - which methods should be left for the developer to implement?

        All concept prototypes are welcome!

        Fully functioning implementations are even better :)

      • Henrik Paul commented  ·   ·  Flag as inappropriate

        I disagree. I think it should be up to the implementation of the 'streamer' to decide which interfaces it wants to implement.

      • Kim L commented  ·   ·  Flag as inappropriate

        This container would need to implement Container.Sortable, Container.Indexed and Container.Filterable for it to actually be usefull

      Feedback and Knowledge Base