Question

I'm having trouble to understand why valueChangeListener isn't triggered. I came accross this topic valueChangeListener Not fired when rendered/disabled attribute is added but it didn't help so much.

When my xhtml is this :

<h:inputText value="#{cm.reference}" 
                    rendered="#{cm.endDate eq null}"
                    valueChangeListener="#{userDataBean.ContactMethodChanged}" />

it's working (I mean the valueChangeListener is triggered)

But when I try this :

<h:inputText value="#{cm.reference}" 
                    rendered="#{cm.contactMethodId eq param.contactMethodID}"
                    valueChangeListener="#{userDataBean.ContactMethodChanged}" />

it doesn't.

Unfortunately I need to have the second option working.

More info :
I'm inside a h:dataTable where I iterate on a list of ContactMethod (cm)
UserDataBean is applicationScoped
Apache Tomcat 7.0
JSF 2.2 (Mojarra 2.2.0)

Thank you for any help.

Était-ce utile?

La solution

If the input is not processed during the form submit, then that can only mean that the rendered attribute didn't evaluate true during processing the form submit, which in turn can only mean that the #{cm.contactMethodId} has incompatibly changed (e.g. because it's a request scoped bean property instead of a view scoped bean property) and/or that #{param.contactMethodID} isn't present during the form submit.

Provided that the bean is in the right scope for the job (otherwise the original rendered approach would likely not have worked either), then retaining the request parameter as follows in the command button/link responsible for submitting the form should do it:

<h:commandButton ...>
    <f:param name="contactMethodID" value="#{param.contactMethodID}" />
</h:commandButton>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top