ValueChangeListener Pitfalls

I've run into a problem with my ValueChangeListener not firing. The same code works fine on a different page, so I'm assuming that the addition of different components is probably the root of my problem. This is what I have:

JSF

<h:form>

...

<h:panelGrid styleClass="popup" rendered="#{RFPdetail.laPopUp}" cellpadding="0" cellspacing="0">

<h:outputText value="Update Lead Agency" styleClass="popUpTitle"/>

<h:outputText value=" " styleClass="separator"/>

<h:panelGroup id="group_section">

<h:selectOneMenu id="custGroup" value="#{RFPdetail.laCustGroup}" onchange="submit()"

valueChangeListener="#{RFPdetail.custGroupChanged}"

styleClass="H2"

immediate="true">

<f:selectItem itemValue="" itemLabel="Select the customer's group"/>

<f:selectItems value="#{prDetail.custGroups}"/>

</h:selectOneMenu>

</h:panelGroup>

<h:panelGroup>

<h:selectOneListbox id="cust" value="#{RFPdetail.cust}" size="10"

rendered="#{not empty RFPdetail.laCustGroup}"

onchange="submit()"

immediate="true"

valueChangeListener="#{RFPdetail.custSelected}">

<f:selectItems value="#{RFPdetail.custs}"/>

</h:selectOneListbox>

</h:panelGroup>

<h:outputText value=" " styleClass="separator"/>

<h:panelGrid columns="2" cellpadding="10px">

<h:commandButton value="Save" action="#{RFPdetail.laSelected}"

disabled="#{empty RFPdetail.laCustGroup}"

immediate="true"/>

<h:commandButton value="Cancel" action="#{RFPdetail.closeLaPopup}" immediate="true"/>

</h:panelGrid>

<h:outputText value="fk_cust_contact_id: #{RFPdetail.cust}"/>

</h:panelGrid>

...

</h:form>

ValueChangeListener in RFPdetail

publicvoid custSelected(ValueChangeEvent vce){

FacesContext context = FacesContext.getCurrentInstance();

System.out.println("Please tell me it worked this time: "+ vce.getNewValue());

setCust((Integer) vce.getNewValue());

setLaSaveDisabled(false);

context.renderResponse();

}

What are some of the things that can conflict with an Value Change Listener?

Thanks

[3460 byte] By [James_Ra] at [2007-10-2 8:54:00]
# 1
Oops! I should note that the first valueChangeListener (custGroupChanged) works fine. It is the second that does not fire (custSelected).
James_Ra at 2007-7-16 22:57:53 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
(1) If you don't put <h:messages/> in your pages, put it into all your pages.(2) If your RFPdetail bean is in request scope, put it in session scope.Search this forum discussions about rendered properties and beans' scope.
yuki.yoshidaa at 2007-7-16 22:57:53 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Hi yuki.yoshida,

Thanks for the observations. I do have the <h:messages> tag and the bean is set to session scope. I should have mentioned these two important details.

However, the ValueChangeListener is still not being called. The System.out line is not printing anything to the console. I commented out all of the other components on the page to reduce the risk of conflict between components.

I'm wondering if I need to manipulate the Phases somehow.

James_Ra at 2007-7-16 22:57:53 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Is "#{not empty RFPdetail.laCustGroup}" a legal expression?However, I guess it's not a main cause...Don't you really see some error message like "Value is not valid"displayed by <h:messages/>?
yuki.yoshidaa at 2007-7-16 22:57:53 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Hello again,

Incidentally, 'empty' and 'not empty' work great.

I solved my problem last night by stepping back and examining my logic. There really was no reason to use a ValueChangeListener for what I was trying to accomplish. I removed it and was immediately greeted by a "value is not valid" message. It didn't show up before, but I'll bet you're correct that it was at the root of the issue. At any rate, the crisis is over and things are working well.

Thanks again for your help on this (and so many other) problems.

James_Ra at 2007-7-16 22:57:53 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...