Wrong event generated on value change for autocomplete

UI Components for JSF
Post Reply
porthos
Posts: 122
Joined: 09 May 2011, 03:17

11 Nov 2011, 02:40

Hello PF devs - is it expected that the ajax behaviour for the "change" event is of class javax.faces.event.AjaxBehaviorEvent rather than javax.faces.event.ValueChangeEvent?

Or should I log a bug for this?

Code: Select all

      <p:autoComplete id="address" value="#{myBean.value}" completeMethod="#{myBean.getSuggestions}">
        <p:ajax event="change" listener="#{myBean.valueChanged}"/>
      </p:autoComplete>

Code: Select all

public class MyBean {
    public void valueChanged(AjaxBehaviorEvent event) { // this method is called }
    public void valueChanged(ValueChangeEvent event)  { // this method is NOT called }
}
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

arturo
Posts: 90
Joined: 23 Aug 2011, 09:57
Location: Mexico

11 Nov 2011, 07:53

the event generated by p:ajax or f:ajax tag is of class javax.faces.event.AjaxBehaviorEvent.

In the case of p:autoComplete, you should listen for the itemSelect event, that extends AjaxBehaviorEvent.

See the instant selection example:
http://www.primefaces.org/showcase-labs ... Select.jsf
PrimeFaces 4.0 | Extensions 1.1.0 | GlassFish 4.0 | Mojarra 2.2.4 | NetBeans 7.3.1

porthos
Posts: 122
Joined: 09 May 2011, 03:17

11 Nov 2011, 13:22

Yes, thanks. I listen for the itemSelect event as well, but this is only fired when you select an item from the suggestions list. If you type a custom value not in the list, it fires the change event, but not the itemSelect event.

This is a change from M3. In M3 a custom value fired the itemSelect event as well, the change event was never fired.

I think the M4 behaviour is better, as it makes it easier to distinguish whether a custom value was entered, or a suggestion was accepted. So I think it's important it should fire the correct event type.
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

porthos
Posts: 122
Joined: 09 May 2011, 03:17

05 Dec 2011, 15:36

Filed a bug for this as a regression from 3.0.M3 and 2.X on the itemSelect event: http://code.google.com/p/primefaces/iss ... il?id=2977
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests