Optional valueChangeListener for h:selectonemenu

Here is an implementation of the needed tag handler:

public final class ValueChangeListenerHandler extends TagHandler {

private final static Class[] VALUECHANGE_SIG = new Class[] {ValueChangeEvent.class};

private final TagAttribute value;

public ValueChangeListenerHandler(TagConfig config) {
value = this.getRequiredAttribute("value");

* (non-Javadoc)
* @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
* javax.faces.component.UIComponent)
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, ELException {

if (parent instanceof EditableValueHolder) {
if (ComponentSupport.isNew(parent)) {
((EditableValueHolder) parent).addValueChangeListener(new
value.getMethodExpression(ctx, null, VALUECHANGE_SIG)));
} else {
throw new TagException(this.tag, "Parent is not of type EditableValueHolder, type is: " + parent);


h:selectonemenu value="#{value}"
c:if test="#{not empty changeListener and changeListener}"
custom:valuechangelistener value="#{backing.selectOneMenuChanged}"

Too bad Blogger doesn't have support for displaying code.


Popular posts from this blog

Крачка назад във вечния танц

Concatenate rows in Oracle