I have two variables \"userId\" and \"name\". When I click for example the \"SHOW USERID\" button it works fine and sets \"renderUserId=true\" and it shows it with the \"ren
There's a major misconception going here. That's not a backing bean. That's a backing component.
JSF UI component instances are not view scoped, instead they are request scoped. They are destroyed by end of render response (after having saved their state into JSF view state) and recreated during view build time (and their state is restored from JSF view state).
You've assigned the stateful properties as instance variables of the component. This is not right. You should be explicitly storing them in the JSF state. The correct approach for that is to let the getter and setter delegate to UIComponent#getStateHelper(). Any attributes which are declared as
already implicitly do that. You do absolutely not need to redeclare them as instance variables of the backing component.
Those booleans which are not declared as
must be reimplemented like follows:
public Boolean getRenderUserId() {
return (Boolean) getStateHelper().eval("renderUserId", Boolean.FALSE);
}
public void setRenderUserId(Boolean renderUserId) {
getStateHelper().put("renderUserId", renderUserId);
}
In your action(listener) method, just invoke setRenderUserId(true)
accordingly.
Don't forget to fix the EL expressions accordingly:
#{cc.renderUserId}