<h:form id="tables">
<p:dataTable id="tabela" value="#{cadProtocoloBean.protocolos}"
var="protocolo" emptyMessage="Não há registro há exibir!"
paginator="false" rows="50" widgetVar="protocoloTabela"
filteredValue="#{cadProtocoloBean.protocolosFiltrados}" >
<f:facet name="header">
<p:outputPanel style="float:right;">
<h:outputText value="Procurar: " />
<p:inputText id="globalFilter"
onkeyup="protocoloTabela.filter()" style="width:150px" />
</p:outputPanel>
</f:facet>
<p:column headerText="Editar/Excluir">
<p:commandButton icon="ui-icon-arrowrefresh-1-w"
action="#{cadProtocoloBean.setProtocolo(protocolo)}"
update="@(:editar)" />
<p:commandButton id="showDialogButton"
onclick="confirmation.show()" icon="ui-icon-close" title="Views">
<f:setPropertyActionListener value="#{protocolo}"
target="#{cadProtocoloBean.protocoloSelecionado}" />
</p:commandButton>
</p:column>
<p:column headerText="Núm. Protocolo"
filterBy="#{protocolo.codProtocolo}" filterMatchMode="exact">
<h:outputText value="#{protocolo.codProtocolo}" />
</p:column>
</p:dataTable></h:form>
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.apache.commons.mail.EmailException;
import org.primefaces.model.StreamedContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope("request")
public class CadProtocoloBean {
@Autowired
private ICadProtocolo protocoloService;
@Autowired
private IUsuarioService usuarioService;
private Protocolo protocolo = new Protocolo();
private Protocolo protocoloSelecionado;
private List<Protocolo> protocolos = new ArrayList<Protocolo>();
private List<Protocolo> protocolosFiltrados = new ArrayList<Protocolo>();
private StreamedContent arquivoRetorno;
private int tipoRelatorio;
private int diasEmAberto;
private String msg, msgDetalhe, messager;
private Severity tipoMsg = FacesMessage.SEVERITY_INFO;
public void excluir() throws FalhaDeExclusaoException,
FalhaDePesquisaException {
if ((enviaEMAILService.listarEmails(this.protocoloSelecionado)
.isEmpty())
&& (enviaSMSService.listarMensagens(this.protocoloSelecionado)
.isEmpty())) {
protocoloService.delete(this.protocoloSelecionado);
protocolos.remove(this.protocoloSelecionado);
protocolosFiltrados.remove(this.protocoloSelecionado);
protocolo = new Protocolo();
benf = new Beneficiario();
coop = new Cooperado();
MensagemBean.mensagem(FacesMessage.SEVERITY_INFO,
"Protocolo excluído com sucesso", "");
} else {
tipoMsg = FacesMessage.SEVERITY_WARN;
msg = ("Este protocolo não pode ser excluído porque já foi enviado e-mail.");
msgDetalhe = ("");
mensagem();
}
}
public Protocolo getProtocolo() {
return protocolo;
}
public void setProtocolo(Protocolo protocolo) {
this.coop = protocolo.getCooperado();
this.benf = protocolo.getBeneficiario();
this.protocolo = protocolo;
}
<?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/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>ProtocoloDeAtendimento</display-name>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
/WEB-INF/applicationContext-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
40
</session-timeout>
</session-config>
<error-page>
<exception-type>
javax.servlet.ServletException
</exception-type>
<location>
/publico/login.xhtml
</location>
</error-page>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<welcome-file-list>
<welcome-file>publico/login.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<resource-ref>
<description>DataSource protocolo</description>
<res-ref-name>jdbc/protocolo</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Mail Session</description>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>hot-sneaks</param-value>
</context-param>
</web-app>
<?xml version="1.0"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude" 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">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>