0

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
perissf
  • 15,979
  • 14
  • 80
  • 117
Mohamed Uvais M
  • 185
  • 1
  • 2
  • 14

1 Answers1

5

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

Community
  • 1
  • 1
perissf
  • 15,979
  • 14
  • 80
  • 117