java - Primefaces InputSwitch 组件在 Ajax 请求后复制

标签 java ajax primefaces

在网络应用程序中,有一个表单供用户注册一些值,其中之一是前缀。当选择前缀值时,selectCheckboxMenu (ajax) 填充了 Executivos 值。这工作正常,如果用户单击“保存”按钮,它就会正确保留在数据库中。

<p:outputLabel value="#{adeBundle.CreateDemandasLabel_prefixo}" for="prefixo" />
<h:panelGroup>
    <p:selectOneMenu id="prefixo" value="#{demandasController.selected.prefixo}"  converter="prefixosConverter" filter="true" filterMatchMode="contains" required="true" requiredMessage="#{adeBundle.CreateDemandasRequiredMessage_prefixo}" >
        <f:selectItem itemLabel="#{adeBundle.SelectOneMessage}" itemValue="#{null}" />
        <f:selectItems value="#{prefixosController.items}"
                       var="prefixoItem"
                       itemValue="#{prefixoItem}"
                       itemLabel="#{prefixoItem.prefixo} - #{prefixoItem.nomePrefixo}"
                       />
        <p:ajax event="valueChange" update="uorPosCollection" listener="#{demandasController.changePrefixo}"/>                            
    </p:selectOneMenu>
    <p:tooltip for="prefixo" value="#{demandasController.getComponentMessages('prefixo', adeBundle.CreateDemandasHelpText_prefixo)}"/>
</h:panelGroup>

<p:outputLabel value="#{adeBundle.CreateDemandasLabel_uorPosCollection}" for="uorPosCollection" />
<p:selectCheckboxMenu id="uorPosCollection" value="#{demandasController.selected.uorPosCollection}" label="Executivo(s)" multiple="true" 
                      converter="uorPosConverter" filter="true" filterMatchMode="contains" panelStyle="width:420px" dynamic="true" title="Selecione um ou mais..." >
    <f:selectItems value="#{demandasController.availableExecutivos}"
                   var="uorPosCollectionItem"
                   itemValue="#{uorPosCollectionItem}"
                   itemLabel="#{uorPosCollectionItem.matricula} - #{uorPosCollectionItem.nome} (#{uorPosCollectionItem.prefixo.prefixo})"
                   >
         <p:inputSwitch disabled="#{demandasController.selected.uorPosCollection.size()==0}" value="#{demandasController.valueOnExecutivo}" onLabel="Sim" offLabel="Não" showLabels="true" style="float: right"><p:ajax listener="#{demandasController.addEmailAdviseMessage}" update=":growl" /></p:inputSwitch>
         <p:outputLabel value="Enviar e-Mail:&nbsp;" style="float: right; padding-top: 0.5em" />
    </f:selectItems>
    <p:tooltip for="uorPosCollection" value="#{demandasController.getComponentMessages('uorPosCollection', adeBundle.CreateDemandasHelpText_uorPosCollection)}"/>
</p:selectCheckboxMenu>

问题是:每次用户选择 Prefixo 时,inputSwitch是重复的:

enter image description here

有谁知道为什么会发生这种情况以及如何解决它?

提前致谢。

最佳答案

您必须输入您的 <p:inputSwitch><f:selectItems> 。 然后输入<p:ajax>更新 inputSwitch 值。

关于java - Primefaces InputSwitch 组件在 Ajax 请求后复制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51862996/

相关文章:

javascript - 选择复选框时显示数据

html - 更改 <p :menubar> CSS into RTL

java - 数据库中的 primefaces 图形图像未加载

java - 同步块(synchronized block)和变量作用域

java - 使用 WebApplicationInitializer 而不是 web.xml 进行 Maven 构建

jquery - 如何从node.js-express获取响应返回ajax

javascript - Rails + simple_form + Remote_true + 自定义 Controller : how to handle different form actions for 'new' and 'edit' ?

jsf - p :commandButton action throws javax. el.PropertyNotFoundException

java - 不区分大小写的排序集 - 保留相同的字符串但大小写不同

java - 在 Ubuntu 上的 Eclipse 中设置 Tomcat