Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从Primefaces不完成';无法使用文件上载和对话框_Java_Jsf_File Upload_Dialog_Primefaces - Fatal编程技术网

Java 从Primefaces不完成';无法使用文件上载和对话框

Java 从Primefaces不完成';无法使用文件上载和对话框,java,jsf,file-upload,dialog,primefaces,Java,Jsf,File Upload,Dialog,Primefaces,我在primefaces的文件上传和对话方面遇到了很多问题 我有一个按钮,当它被点击时调用一个对话框。在这个对话框中,我有一个文件上传。当我选择某个文件并更新表单上的图像时,我希望此对话框关闭。 代码如下: <h:form id="formCadastroSistema"> <div id="divCadastroComponenteConstrutivo"> <h:outputText value="Cadastro de Componente Con

我在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"

请同时参考此项。

是的,比如说user1351585,更改您的id=“dialogUpload”的名称 并在web.xml上添加以下代码:

<filter>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

PrimeFaces文件上载筛选器
org.primefaces.webapp.filter.FileUploadFilter
PrimeFaces文件上载筛选器
Facesservlet

某些Primefaces功能在IE上无法正常工作(除非您进行了一些变通),特别是在使用旧版本时。查看Primefaces论坛以检查您的IE版本兼容性,可能有人已经就此提出了一些问题。Primefaces在版本3.5之前应该与IE 7兼容。所以你不应该有问题。问题是文件上传的更新和oncomplete在IE上不起作用。当我刷新页面时,图像changes@DiegoSabino,尝试将
enctype=“multipart/form data”
添加到您的
你好,丹尼尔,我尝试过这样做,但没有成功。有些东西不允许update和oncomplete在fileupload上工作。这种情况只发生在internet Explorer上,我更改了组件ID和widgetVar,但问题仍然存在。图像未更新,对话框未关闭问题是文件上载的更新和oncomplete在IE上不起作用。当我刷新页面时,图像会发生变化。