Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Arrays$ArrayList with modifiers "public"

Tags:

jsf

el

jsf-2

I have such an p:selectManyCheckbox and it works ok:

<p:selectManyCheckbox id="groups" value="#{myBean.selectedGroups}">
    <f:selectItems value="#{myBean.myGroups}" var="group" itemValue="#{group.id}" itemLabel="#{group.name}"/>
</p:selectManyCheckbox>

Now I have to convert it to the Tree component (adding Group parent to data), but my PrimeFaces version 3.4.1. doesn't support such a functionality. For better customization I decided to make this selectManyCheckbox manually with html and <ui:repeat>):

<div id="j_idt25groups" class="ui-scrollpanel ui-scrollpanel-native ui-widget ui-widget-content ui-corner-all" style="height: 200px;">
    <table id="groups" class="ui-selectmanycheckbox ui-widget">
        <tbody>
            <ui:repeat value="#{myBean.myGroups}" var="group" varStatus="status">
                <tr>
                    <td>
                        <div class="ui-chkbox ui-widget">
                            <div class="ui-helper-hidden-accessible">
                                <ui:fragment rendered="#{myBean.selectedGroups.contains(group.id)}">
                                    <input id="groups:#{status.index}" name="groups" type="checkbox" value="#{group.id}" 
                                                       checked="checked">
                                    </input>
                                </ui:fragment>
                                <ui:fragment rendered="#{not myBean.selectedGroups.contains(group.id)}">
                                    <input id="groups:#{status.index}" name="groups" type="checkbox" value="#{group.id}">
                                    </input>
                                 </ui:fragment>
                             </div>
                             <div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default">
                                  <span class="ui-chkbox-icon"></span>
                             </div>
                         </div>
                     </td>
                     <td>
                        <label for="groups:#{status.index}">#{group.name}</label>
                    </td>
                </tr>
            </ui:repeat>
        </tbody>
    </table>
</div>

Now i have a problem with this code #{prpBean.selectedGroups.contains(group.id)}:

java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Arrays$ArrayList with modifiers "public"

Is it possible to solve this problem? Does it exists an easier way to convert such a structure to the Tree?

like image 509
Darkwing Avatar asked Aug 07 '15 09:08

Darkwing


1 Answers

The contains() method of java.util.Arrays$ArrayList is not immediately accessible by Java reflection. This could be a (corner case) bug in the EL implementation being used. It may work in a different EL implementation. It may be worth a bug report to the EL implementation vendor, but it is what it is.

When creating selectedGroups, use new ArrayList() instead of Arrays#asList() and all should be well.

like image 142
BalusC Avatar answered Sep 30 '22 05:09

BalusC