Boa tarde pessoal,
estou passando por aquele problema: ontem no meu notebook o codigo funcionava, hj eu transportei o codigo para uma maquina da empresa e advinhem ? Isso mesmo, meu código não funfou.
bom… vamos ao que interessa…
estou tentando fazer um fileupload do primefaces, mas o problema é que ele não executa o método, ou seja, ele passa todo o ciclo… da view e tudo mais… mas ele não entra no model, e por isso, ele não executa meu método do upload. Se alguem puder me ajudar, eu dei uma olhada hj e não consegui enxergar a solução.
Aqui está um trecho do meu xhtml:
<p:fileUpload imagem="/img/upload32.png" widgetVar="uploader" multiple="false"
fileUploadListener="#{cotacaoBean.upload}" allowTypes="*.csv;" description="Images" customUI="true" />
<h:outputLink title="upload" onclick="uploader.upload();">
Upload
</h:outputLink >
Aqui meu método …
public void upload(FileUploadEvent evento){
byte[] arquivoUpload = evento.getFile().getContents();
................
Aqui está a configuração do meu 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>
<filter-class> Faces Servlet</filter-class>
</filter-mapping>
Meu ManagedBean é do tipo @RequestScope e eu tenho as classes >> commons-fileupload-1.2.2 e commons-io-2.1
… alguém saberia me ajudar ?
Cara… se tava funcionando na tua máquina e não funcionou na máquina da empresa não seria esquema de segurança?
Não não, porque a máquina da empresa que tem aqui, ela não está em rede e não tem qualquer método de segurança de acesso ou algo do tipo …
EuclidesFilizola blz?
Cara to passando pelo mesmo problema…
Você conseguiu achar a solução?
No seu notebook você disse que ta funcionando… você poderia postar o código e me dizer que versão
do primefaces você ta utilizando?
Vlw brother ;D
Por favor, post o seu web.xml completo e o faces-config.xml tbm. Ah! E coloque a versão do Primefaces que utiliza e a versão do JSF.
benignoms,
Meu web.xml
[code]<?xml version=“1.0” encoding=“UTF-8”?>
<web-app xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns=“http://java.sun.com/xml/ns/j2ee” xmlns:web=“http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd”
xsi:schemaLocation=“http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”
id=“WebApp_ID” version=“2.4”>
<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>
<filter>
<filter-name>FilterBloqueaPaginas</filter-name>
<filter-class>br.com.acessavale.controller.security.FilterPaginasBloqueadas</filter-class>
</filter>
<filter-mapping>
<filter-name>FilterBloqueaPaginas</filter-name>
<url-pattern>/menu/</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Config</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Config</servlet-name>
<url-pattern>.faces</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>home.faces</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>ImageServlet</servlet-name>
<servlet-class>br.com.acessavale.servlet.ImageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageServlet</servlet-name>
<url-pattern>/ImageServlet</url-pattern>
</servlet-mapping>
</web-app>[/code]
Meu faces-config.xml
[code]<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns=“http://java.sun.com/xml/ns/javaee”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd”
version=“2.0”>
<lifecycle>
<phase-listener>br.com.acessavale.controller.ListenerFases</phase-listener>
</lifecycle>
<managed-bean>
<managed-bean-name>loginBBean</managed-bean-name>
<managed-bean-class>br.com.acessavale.controller.LoginBBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>cadastroBBean</managed-bean-name>
<managed-bean-class>br.com.acessavale.controller.CadastroBBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>PromocaoBBean</managed-bean-name>
<managed-bean-class>br.com.acessavale.controller.PromocaoBBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>novidadesBean</managed-bean-name>
<managed-bean-class>br.com.acessavale.controller.NovidadesBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>fotoBBean</managed-bean-name>
<managed-bean-class>br.com.acessavale.controller.FotoBBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>[/code]
A versão jsf que to usando é a 2.1.3
E a versão do primefaces é a 3.0.M4
Depois de muita dor de cabeça finalmente consegui fazer o upload
de arquivos funcionar com o Primefaces M4
As mudanças mais significativas foram no web.xml que acredito que estava
mal configurado no projeto
vou postar aqui caso possa ajudar alguem
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
id="WebApp_ID" version="2.4">
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<filter>
<filter-name>FilterBloqueaPaginas</filter-name>
<filter-class>br.com.acessavale.controller.security.FilterPaginasBloqueadas</filter-class>
</filter>
<filter-mapping>
<filter-name>FilterBloqueaPaginas</filter-name>
<url-pattern>/menu/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>home.faces</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>ImageServlet</servlet-name>
<servlet-class>br.com.acessavale.servlet.ImageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageServlet</servlet-name>
<url-pattern>/ImageServlet</url-pattern>
</servlet-mapping>
<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>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>