1

Maybe someone can help me with this: I've got a dataTable and it's populated by ArrayList<> and when I try to update this dataTable after causing some changes in it I've got an exception

SEVERE [http-apr-8080-exec-1] com.sun.faces.renderkit.html_basic.MenuRenderer.createCollection Unable to create new Collection instance for type java.util.Arrays$ArrayList java.lang.InstantiationException: java.util.Arrays$ArrayList

Caused by: java.lang.NoSuchMethodException: java.util.Arrays$ArrayList.()

I saw similar questions on SOF but, unfortunatly, it's no use for me. (my ArrayList doesn't instantiated by Arrays.asList). My app works fine, but I need to remove this exception.

this is a part of my .xhtml where dataTable is define:

<p:dataTable id="columnsDef"
   widgetVar="columnsList"
   value="#{setup.columnWrapperList}"
   var="columnVar"
   rowKey="#{columnVar.wrappedColumnId}"
   selectionMode="single"
   selection="#{setup.selectedColumn}"
   lazy="false"
   rows="10"
   paginator="false"
   style="width: 100%"
   emptyMessage="#{msg['common.emptyMsg']}"
   resizableColumns="true"
   filterEvent="enter"
   tableStyle="width: auto">

here is part of .xhtml whre setup.columnWrapperList updated

<div class="left">
            <p:commandButton icon="ui-icon-triangle-1-n"
                             actionListener="#{setup.decOrder}"
                             update="@([id$=columnsDef])"
                             />
            <p:commandButton icon="ui-icon-triangle-1-s"
                             actionListener="#{setup.incOrder}"
                             update="@([id$=columnsDef])"
                             />
        </div>

and finaly part of "setup" bean that cause changes in ArrayList:

    public void decOrder() {
    int i = selectedColumn.getOrder();
    if (i > 0) {
        columnWrapperList.get(i).setOrder(i - 1);
        columnWrapperList.get(i - 1).setOrder(i);
        columnWrapperList.sort(new Comparator<ColumnWrapper>() {
            @Override
            public int compare(ColumnWrapper o1, ColumnWrapper o2) {
                return o1.getOrder() < o2.getOrder() ? -1 : 1;
            }
        });
    }
}

can some one help me please?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Bender
  • 617
  • 6
  • 17
  • Hello dear @BalusC I carefuly read your answers, before asking this question, and still can't find answers to help my problem (I understand that it's the same field of errors). You mark my question as duplicate with reference to [link](http://stackoverflow.com/questions/17359226/jsf-selectmanycheckbox-for-enum-severe-unable-to-create-new-collection-instan) but in this question you suggest to check Arrays.asList initialization for ArrayList so I did it (check for immutable collection) and I've got none. May be you can propose more comprehensive solution? Thank you! – Bender Jul 28 '16 at 11:40
  • Also here is a usage for columnWrapperList and there is no Arrays.asList http://puu.sh/qhmEi/437d845a51.png – Bender Jul 28 '16 at 11:58
  • This has nothing to do with your data table. The exception is coming from `MenuRenderer` which is only used on multi-selection `selectXxx` components such as ``. – BalusC Jul 28 '16 at 12:09
  • Oh yeah! Thank you .. I "realy" carefuly read your unswers from [this](http://stackoverflow.com/questions/17359226/com-sun-faces-renderkit-html-basic-menurenderer-createcollection-unable-to-crea) and [that](http://stackoverflow.com/questions/25245426/org-hibernate-lazyinitializationexception-at-com-sun-faces-renderkit-html-basic/25249537#25249537) than look for selectMany in my page add and now it works just fine! @BalusC Thank you again :) – Bender Jul 28 '16 at 12:55

1 Answers1

-1

It works without the sort? If so, try to sort with Collections.sort:

Collections.sort(columnWrapperList, new Comparator<ColumnWrapper>() {
    @Override public int compare(ColumnWrapper o1, ColumnWrapper o2) {
        return Integer.compare(o1.getOrder(), o2.getOrder());
    }
});
Victor T.
  • 121
  • 3
  • Thanks, but it works just the same. As far as I know it's the same thing, except the method of invocation (static or from the object). – Bender Jul 28 '16 at 11:17
  • By the way - excluding sorting doesn't affect on exception. – Bender Jul 28 '16 at 11:28