Problem to disable the p:selectOneMenu during the ajax event

323 Views Asked by At

I am trying to disable the combobox when it processes the ajax event, but it sends null to the bean setter instead of the selected value. It sends the correct value once I remove the code onstart="PF('testA').disable();".

Does anyone have a solution for this. Thanks.

I am using Primefaces 6.2, JSF2.2, Java 7 and Glassfish 4.1.

<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:p="http://primefaces.org/ui">

<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />     
</h:head>
<h:body>
    <h:form id="themeForm">
            <p:selectOneMenu value="#{selectOneMenuViewA.theme}" widgetVar="testA">
                <p:ajax process="@form" event="itemSelect" update=":themeForm:themeId" onstart="PF('testA').disable();" oncomplete="PF('testA').enable()"/>  
                <f:selectItems value="#{selectOneMenuViewA.themes}" var="theme" itemLabel="#{theme}" itemValue="#{theme}" />
            </p:selectOneMenu>
            <h:outputText id="themeId" value="#{selectOneMenuViewA.theme}"/>
    </h:form>
</h:body>

public class SelectOneMenuViewA {

private String theme;   
private List<String> themes;

@PostConstruct
public void init() {        
    themes = Arrays.asList("a", "b", "c");
}

public String getTheme() {
    return theme;
}

public void setTheme(String theme) {
    this.theme = theme;
}

public List<String> getThemes() {
    return themes;
}
}
0

There are 0 best solutions below