p:ajax is not working on Primefaces 13 when change value from selectOneMenu

25 Views Asked by At

i am in charge to migrate a project from primefaces 6.3 to primefaces 13, i am following the official documentation for this...

Everything is working fine! but i have a lot of issues when i use p:ajax to handle events...

I have a SelectOneMenu component and i want to update the Bean with the function onTipoPersonaSelected() when the select changes his value, but the ajax event listener is not working for some reason!

I have made a little example of the problem that i am facing:

page.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/XHtml.xhtml to edit this template
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <head>
        <title>TODO supply a title</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    </head>
    <body>
        <f:metadata>
                <f:viewAction action="#{receptorCreatorManager.prepareNew()}" />
                <f:viewAction action="#{delegacionFinderManager.filter(receptorControllerBean.selected)}"/>
            </f:metadata>
            <h:form>
                <p:autoUpdate/>
                    <p:selectOneMenu id="tipoPersonaSelector" value="#{receptorControllerBean.tipoPersona}">
                        <f:selectItems value="#{receptorControllerBean.tiposPersona}" />
                        <p:ajax listener="#{receptorCreatorManager.onTipoPersonaSelected(event)}" event="valueChange" update="@form" process="@this"/>
                    </p:selectOneMenu>

            </h:form>
    </body>
</html>

this is my Bean Component where it should handle the event:

@Named
@ViewScoped
public class ReceptorCreatorManager extends EFacturaWebAbstractManagedBean implements Serializable {
    public void onTipoPersonaSelected(AjaxBehaviorEvent event) {
        System.out.println("ENTER!");
    }
}

In summary, what I want to do is that when the select changes its value, it enters onTipoPersonaSelected(), but currently it is not entering the function for some reason, and i dont really know what else i can do..

I am following the official doc of PF 13 for this:

https://primefaces.github.io/primefaces/13_0_0/#/components/selectonemenu?id=selectonemenu

Anyone could help me with this?

Thanks!

0

There are 0 best solutions below