webtier@glassfish.java.net

2nd value change listener won't fire

From: <webtier_at_javadesktop.org>
Date: Tue, 15 Jun 2010 12:17:16 PDT

I've got three selectonemenus, the first is enabled and you can
select a sport, the other two are initially disabled. When selected
the 2nd menu is enabled and you can select a club, which when
selected should enable the third field allowing you to select a squad.

The problem is that the 2nd field gets enabled as expected but
not the third. The mechanism used is exactly the same in both
cases, i.e. to use a valuechangelistener with ajax. Here's the code:

[code]
<h:outputLabel for="sport">#{msgs.sportLabel}&nbsp;</h:outputLabel>
                    <h:selectOneMenu id="sport" value="#{clubView.pageSport}"
                                     valueChangeListener="#{clubView.enableInputClub}"
                        <f:selectItem itemLabel="#{msgs.selectOneLabel}" noSelectionOption="true"/>
                        <f:selectItems value="#{appView.sportList}"/>
                        <f:ajax render="club"/>
                    </h:selectOneMenu>
                    
                    <h:outputLabel for="club">#{msgs.clubLabel}&nbsp;</h:outputLabel>
                    <h:selectOneMenu id="club" value="#{clubView.pageClub}"
                                     binding="#{clubView.inputClub}"
                                     disabled="true"
                                     valueChangeListener="#{clubView.enableInputSquad}"
                        <f:selectItem itemLabel="#{msgs.selectOneLabel}" noSelectionOption="true"/>
                        <f:selectItems value="#{clubView.clubList}"/>
                        <f:ajax render="squad"/>
                    </h:selectOneMenu>
                    
                    <h:outputLabel for="squad">#{msgs.squadLabel}&nbsp;</h:outputLabel>
                    <h:selectOneMenu id="squad" value="#{clubView.pageSquad}"
                                     binding="#{clubView.inputSquad}"
                                     disabled="true"
                        <f:selectItem itemLabel="#{msgs.selectOneLabel}" noSelectionOption="true"/>
                        <f:selectItems value="#{clubView.squadList}"/>
                    </h:selectOneMenu>
[/code]

and from the clubView backing bean:

[code]
private HtmlSelectOneMenu inputClub, inputSquad;

public void enableInputClub(ValueChangeEvent vce) {
        if (getInputClub().isDisabled() == true) {
            getInputClub().setDisabled(false);
        }
    }

public void enableInputSquad(ValueChangeEvent vce) {
        if (getInputSquad().isDisabled() == true) {
            getInputSquad().setDisabled(false);
        }
    }
[/code]

so I've got three components with ids sport (enabled), club (disabled)
and squad (disabled). I select a sport and the "club" component is enabled
by the VCL and re-rendered via ajax. It works fine. I then select a club but
the "squad" selectonemenu component remains disabled because the
enableInputSquad() VCL never fires.

Now I may be suffering from code blindness but I can't see what the difference
is between the first enable and the second. I don't think there is any difference.

If anyone knows any way to do an enable that actually works I'd love to hear
from you as this has been another wasted day.

Thanks,
Brendan.
[Message sent by forum member 'healeyb']

http://forums.java.net/jive/thread.jspa?messageID=474380