I've been studying how to develop JSF custom components to improve my knowledge about how it works (it's been quite interesting so far).
I made my own commandButton (extended from HtmlCommandButton) and it worked as expected when doing all decoding and enconding in the component class.
When I decided to create a separated faces renderer for my component it stopped working. After some research I learned that I had to override the decode method of my renderer and it was working before just because this method was already implemented by HtmlCommandButton.
After some research I found out how to decode action listeners (thanks to BalusC) and I also learnt how to decode ajax events. However I still didn't know how to decode actions.
This is my decode method right now:
@Override
public void decode(FacesContext context, UIComponent component) {
CommandButtonUI commandButton = (CommandButtonUI) component;
//decode click ajax events
List<ClientBehavior> clientBehaviours = commandButton.getClientBehaviors().get("click");
if (clientBehaviours != null) {
for (ClientBehavior cb : clientBehaviours) {
cb.decode(context, component);
}
}
//decode action listenet
if (context.getExternalContext().getRequestParameterMap().containsKey(commandButton.getClientId(context))) {
component.queueEvent(new ActionEvent(component));
}
}
I already tried to find HtmlCommandButton's decode source and analyse it, but I failed to find it, since apparently it's generated by a plugin.