I am using Spring so by default it does not have view scope. I copy an implementation from the web but have some problem to get it to work.
Instead I used session scope which should not make much difference in this case. Using session scope works.
I spent some time debugging to find out why it should depend on the scope. On this simple example, I can not see why it should depend on the scope.
And here is what I found as shown below. In 2.2.1 it checks for if it is disabled (this check implies that I can get the previous state from the backing bean which also implies that the scope of the bean must be view or above). In my case a new backing bean will be created and the initial value is fetched which is false indicating that it is disable. Hence it will not create the ActionEvent. In 2.2RC1, the ActionEvent will be created because there is no check . This method is called during the apply request values phase.
Is this check really necessary?
In 2.2RC1
public class CommandButtonRenderer extends CoreRenderer {
@Override
public void decode(FacesContext facesContext, UIComponent component) {
String param = component.getClientId(facesContext);
if(facesContext.getExternalContext().getRequestParameterMap().containsKey(param)) {
component.queueEvent(new ActionEvent(component));
}
}
In 2.2.1
public class CommandButtonRenderer extends CoreRenderer {
@Override
public void decode(FacesContext facesContext, UIComponent component) {
CommandButton button = (CommandButton) component;
if(button.isDisabled()) {
return;
}
String param = component.getClientId(facesContext);
if(facesContext.getExternalContext().getRequestParameterMap().containsKey(param)) {
component.queueEvent(new ActionEvent(component));
}
}