gpt4 book ai didi

java - Primefaces 的 oncomplete 不适用于文件上传和对话框

转载 作者:行者123 更新时间:2023-12-01 14:52:34 25 4
gpt4 key购买 nike

我在使用 primefaces 的文件上传和对话框时遇到很多问题。

我有一个按钮,单击它时会调用一个对话框。在这个对话框中我有一个文件上传。我希望当我选择某个文件并更新表单上的图像时关闭此对话框。这是代码:

<h:form id="formCadastroSistema">
<div id="divCadastroComponenteConstrutivo">
<h:outputText value="Cadastro de Componente Construtivo" style="font-size: 20px; color: black;"/>
<p:layout style="height:240px; width: 100%; margin-top: 20px; padding-left: 40px;">
<p:layoutUnit position="west" size="330" style="border: none;" resizable="false" >
<p:graphicImage value="#{novoComponenteConstutivo.mostrarImagemDeByte()}" id="foto"/>
<p:commandButton onclick="dialogUpLoad.show();" value="abrir"/>
</p:layoutUnit>
<p:layoutUnit position="center" style="font-size: 14px; border: none;">
<h:panelGrid columns="2" cellspacing="5">
<h:outputText value="Nome: "/>
<p:inputText style="width: 295px;" value="#{novoComponenteConstutivo.novoComponenteConstrutivo.nome}" />
<h:outputText value="Categoria: "/>
<p:selectOneMenu value="#{novoComponenteConstutivo.idCategoriaCamada}" id="selectMenuCategoria" style="width: 305px;">
<f:selectItems value="#{novoComponenteConstutivo.todasAsCategorias}" var="categoria" itemLabel="#{categoria.categoria}" itemValue="#{categoria.id}"/>
<f:ajax event="valueChange" execute="selectMenuCategoria" listener="#{novoComponenteConstutivo.setarCategoriaDoNovoComponente()}" render="testi" />
</p:selectOneMenu>
<h:outputText value="Descrição: "/>
<p:inputTextarea value="#{novoComponenteConstutivo.novoComponenteConstrutivo.descricao}" style="width: 295px; height: 50px;"/>
<h:outputText value="Fabricante: "/>
<p:selectOneMenu value="#{novoComponenteConstutivo.idFabricante}" id="selectMenuFabricante" style="width: 305px;">
<f:selectItems value="#{novoComponenteConstutivo.todosOsFabricantes}" var="fabricante" itemLabel="#{fabricante.nome}" itemValue="#{fabricante.id}" />
<f:ajax execute="selectMenuFabricante" event="valueChange" listener="#{novoComponenteConstutivo.setarFabricanteDoNovoComponente()}" render="testi2" />
</p:selectOneMenu>

</h:panelGrid>
<h:outputText value="#{novoComponenteConstutivo.idCategoriaCamada}" id="testi"/>
<h:outputText value="#{novoComponenteConstutivo.idFabricante}" id="testi2"/>
</p:layoutUnit>
<p:dialog style="height: 300px; width: 500px;" id="dialogUpLoad" widgetVar="dialogUpLoad" >
<p:fileUpload fileUploadListener="#{novoComponenteConstutivo.uploadImagem}" update="foto" oncomplete="dialogUpLoad.hide();" multiple="false" />
</p:dialog>
</p:layout>
<p:separator/>
<p:layout style="height: 150px; padding-left: 40px;" >
<!-- -->
<p:layoutUnit position="center" style="border: none;">
<h:outputText value="Características Físicas" style="font-size: 18px;"/>
<h:panelGrid columns="2" >
<h:panelGrid columns="2" style="font-size: 14px; padding-top: 20px;" >
<h:outputText value="Condutividade Térmica: "/>
<p:inputText value="#{novoComponenteConstutivo.novoComponenteConstrutivo.condutividade}" />
<h:outputText value="Calor Específico: "/>
<p:inputText value="#{novoComponenteConstutivo.novoComponenteConstrutivo.calorEspecifico}"/>
<h:outputText value="Densidade Mínima: " />
<p:inputText value="#{novoComponenteConstutivo.novoComponenteConstrutivo.densidadeMinima}"/>
</h:panelGrid>
<h:panelGrid columns="2" style="font-size: 14px; padding-top: 20px; margin-left: 45px;" >
<h:outputText value="Densidade Máxima: "/>
<p:inputText value="#{novoComponenteConstutivo.novoComponenteConstrutivo.densidadeMaxima}"/>
<h:outputText value="Espessura: "/>
<p:inputText value="#{novoComponenteConstutivo.novoComponenteConstrutivo.espessura}"/>
</h:panelGrid></h:panelGrid>
</p:layoutUnit>
</p:layout>
<h:commandLink value="confirm" style="position: absolute; right: 0px; font-size: 12px;" onclick="showDivConfirmacaoCadastroComponente();" >
<f:ajax execute="@form" render=":formConfimacaoCadastroComponente" event="click" />
</h:commandLink>
</div>
</h:form>

它适用于 google chrome 和 FireFox,但 IE 对话框不会关闭,图像也不会更新。

最佳答案

可能是因为组件 ID 和 widgetVar 相同。

 id="dialogUpLoad" widgetVar="dialogUpLoad"

请引用此SO question也是如此。

关于java - Primefaces 的 oncomplete 不适用于文件上传和对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14694566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com