简体   繁体   English

p:selectOneMenu Ajax更改事件不起作用

[英]p:selectOneMenu ajax change event not working

I have the following component on the xhtml: 我在xhtml上具有以下组件:

            <p:outputLabel for="concept" value="Concept" />
        <p:selectOneMenu id="concept" value="#{dIGRCController.digrc.qconce}"
            requiredMessage="Debe de seleccionar un concepto."
            required="#{request.getParameter('validate')}">

            <f:selectItem itemLabel="Concept" itemValue="" />
            <f:selectItems value="#{cCRX1Controller.ccrx1.concepts.entrySet()}"
                var="concepts" itemValue="#{concepts.key}"
                itemLabel="#{concepts.value}" />

            <p:ajax event="change" execute="@this" listener="#{dIGRCController.testing()}" />

        </p:selectOneMenu>

The values are coming correctly from the cCRX1Controller class. 这些值正确地来自cCRX1Controller类。 However, when I select an option, I am trying to display the value. 但是,当我选择一个选项时,我试图显示该值。 the #{dIGRCController.testing()} looks like this: #{dIGRCController.testing()}如下所示:

public void testing()
{
    System.out.println("sdfsd");
}

What am I doing wrong? 我究竟做错了什么? I checked this question but could't figure out what the problem is. 我检查了这个问题,但不知道是什么问题。

Try with this 试试这个

<p:ajax process="@this" listener="#{dIGRCController.testing()}" />

I think the default of ajax event of Primefaces select one menu is valueChange event. 我认为Primefacesajax事件默认选择一个菜单是valueChange事件。 So, try with using also 因此,请尝试同时使用

<p:ajax event="valueChange" process="@this" listener="#{dIGRCController.testing()}" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM