简体   繁体   中英

Illegal Syntax for Set Operation for Primefaces Boolean CheckBox?

Does the below EL expression for value is a valid one?

<p:selectBooleanCheckbox value="#{!bean.isCreateGroup}" id="checkBoxCreateSecurityGrpKey">

I'm getting the error as

javax.el.PropertyNotWritableException:/pages/popup.xhtml @503,170 value="#{!bean.isCreateGroup}": Illegal Syntax for Set Operation

The expression value="#{!bean.isCreateGroup}" is not valid here because the value attribute of SelectBooleanCheckBox must be a javax.el.ValueExpression that can both get and set a value (l-value expression).

From the linked Javadoc of ValueExpression:

Not all r-value expressions can be used as l-value expressions (eg "${1+1}" or "${firstName} ${lastName}")

And from the Expression Language Specification 2.1:

The valid syntax for an lvalue is a subset of the valid syntax for an rvalue. In particular, an lvalue can only consist of either a single variable (eg ${name}) or a property resolution on some object, via the . or [] operator (eg ${employee.name}).

To make it crystal clear, the expression should represent a bean property:

<p:selectBooleanCheckbox value="#{bean.aBooleanProperty}" ... />    

In your case, the simplest solution is to use another Boolean variable in your bean that has the opposite value, eg something like Boolean notCreateGroup (by the way, why a component referenced with checkBoxCreateSecurityGrpKey should have a value opposite to a variable named createGroup ?).

Se also:

Using conditional operator in h:inputText value and h:commandButton actionListener

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM