0
votes

I am trying to populate selectBooleanCheckbox values using ui:repeat as the values are taken from a list. The checkbox values are assigned fine, but the listener is not called when I change the selectBooleanCheckbox value. I also got this error when changing the value

Illegal Syntax for Set Operation: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation

Here is my code

 <ui:repeat value="#{myBean.myObjects}" var="object">                                                           
    <p:selectBooleanCheckbox 
       value="#{myBean.isObjectSelected(object)}">                                                      
          <p:ajax update="growl"                                                            
             listener="#{myBean.doSomethingtoObject(object)}" />                                                        
    </p:selectBooleanCheckbox>                                                  
    <h:outputText value="#{object.name}" />
</ui:repeat>

The issue comes from value="#{myBean.isObjectSelected(object)}" part. When I removed that part the error is gone and the listener is called fine. But how else would I get the checkbox value without it? Even if I straight away assign the value to be #{true} the listener would not be called. I found similar issues but not with ajax listeners.

1
Tried without a ui:repeat? With a different component than selectBooleanCheckbox and if the error is from #{myBean.isObjectSelected(object)} it is normal the ajax listener is not called. Your question is not related to any of the tags but to EL. So post the error you get in google and start reading...Kukeltje
yep, tried using c:foreach too. Same error shown. I am not sure how else would be effective to iterate a list of objects.Nik Mohamad Lokman
The value of the selectBooleanCheckbox is not taken from any variable. In the isObjectSelected method, I have to check certain values in the Object and later returns a true or false, but thanks for the finding !Nik Mohamad Lokman
You can decorate your objects with a class having a simple boolean selected property with corresponding getters and setters. Then change your ui:repeat value="#{myBean.myObjectDecorators}" var="objectDecorator" and your p:selectBooleanCheckbox value="#{objectDecorator.selected}"Selaron

1 Answers

1
votes

Apparently, the selectBooleanCheckBox must have a predefined value and cannot be populated by calling a method. Solved this by using a Map and keeping the TRUE or FALSE value inside.

<ui:repeat value="#{myBean.myObjects}" var="object">                                                           
    <p:selectBooleanCheckbox 
       value="#{myBean.objectMap[object]}">                                                      
          <p:ajax update="growl"                                                            
             listener="#{myBean.doSomethingtoObject(object)}" />                                                        
    </p:selectBooleanCheckbox>                                                  
    <h:outputText value="#{object.name}" />
</ui:repeat>