Mohamed Uvais M
Mohamed Uvais M

Reputation: 305

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

Upvotes: 0

Views: 2513

Answers (1)

perissf
perissf

Reputation: 16273

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 (e.g. "${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 (e.g. ${name}) or a property resolution on some object, via the . or [] operator (e.g. ${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, e.g. 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

Upvotes: 6

Related Questions