vctlzac
vctlzac

Reputation: 847

JSF 2.0 set attribute bean when event change

I'm using richfaces and trying call method in bean when event component is fired. I want call to directly the "set" attribute.

xhtml:

    h:selectBooleanCheckbox value="#{!mbean.myFlag}" immediate="true">
        <a4j:ajax event="click" immediate="true"></a4j:ajax>
    </h:selectBooleanCheckbox>

Mbean:

@SuppressWarnings("serial")
@ManagedBean(name = "mbean")
@ViewScoped
public class MyMbean implements Serializable {

private Boolean myFlag;   
...

/** @see #myFlag*/
public Boolean getMyFlag() {
    return flagCartaEmitida;
}

/** @see #myFlag*/
public void setMyFlag(Boolean myFlag) {
    this.myFlag= myFlag;
}

...

When click in checkbox get an error:

javax.faces.component.UpdateModelException: org.apache.myfaces.view.facelets.el.ContextAwarePropertyNotWritableException: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation

Thanks.

Upvotes: 1

Views: 2484

Answers (2)

David Angyal
David Angyal

Reputation: 241

I think a getter for a boolean has to be declared as isMyFlag, not getMyFlag.

Upvotes: -1

BalusC
BalusC

Reputation: 1108912

value="#{!mbean.myFlag}"

You can't use this EL syntax for a "set" operation. You should remove the exclamation ! and inverse the value in the model itself so that you can use the proper EL syntax:

value="#{mbean.notMyFlag}"

Upvotes: 8

Related Questions