Bom dia,
tenho uma classe com o metodo que valida o cpf, o login do sistema seria o cpf, agora como poderia usar na jsp a chamada desse metodo??
boolean t = this.f.validacpf( f.tratCPF(this.cpf));
if (t)
{
EntityManager em = getEntityManager();
try{
Query q;
q = em.createQuery("select count(o) from LUsuarios as o where o.cdPessoa.cpf =:p").setParameter("p", f.tratCPF(cpf));
int count = ((Long) q.getSingleResult()).intValue();
if (count == 0)
{
this.setLPessoa(existPessoa());
this.createSetup();
this.lPessoa.setCpf(cpf);
this.cpf = this.lPessoa.getCpf();
response.sendRedirect(this.session.getAttribute("servPath")+ "index2.jsf?path=lUsuarios/New.jsp");
}
else
{
Query q1;
q1 = em.createQuery("select o from LUsuarios as o where o.cdPessoa.cpf =:p").setParameter("p",f.tratCPF(cpf));
this.LUsuarios = (LUsuarios)q1.getSingleResult();
this.lPessoa = this.LUsuarios.getCdPessoa();
this.cpf = this.lPessoa.getCpf();
response.sendRedirect(this.session.getAttribute("servPath")+ "index2.jsf?path=lUsuarios/Edit.jsp");
}
} finally {
em.close();
}
}
else
{
System.out.println;
setMsn("CPF INVÁLIDO");
response.sendRedirect(this.session.getAttribute("servPath")+ "index2.jsf?path=lUsuarios/New1.jsp");
}
}
*****************************************
JSP::
</table>
<div id="Layer1" style="position:absolute; width:308px; height:189px; z-index:1; left: 500px; top: 282px;">
<table id="todoform" width="270" height="169" border="1" bordercolor="#000000" align="center">
<tr bgcolor="#7A826F">
<td height="42" colspan="3"><div align="center"><strong><span class="banner_titulo_web style1"> BEM-VINDO AO PNGEO </span></strong></div></td>
</tr>
<tr>
<td width="97" height="20"><div align="right" size="20" class="banner_titulo_web"><strong>Usuario</strong></div></td>
<td width="163" height="20"><h:inputText required="true" size="20" id="login"/></td>
</tr>
<tr>
<td height="20"><div align="right" class="banner_titulo_web"><strong>Senha</strong></div></td>
<td height="20"><h:inputSecret required="true" id="senha"/></td>
</tr>
<tr>
<td height="20" colspan="2" align="center"> <h:commandButton value="Entrar" action="#{lUsuarios.login}" /></td>
</tr>
<tr bgcolor="#7A826F">
<td height="20" colspan="3"><h:messages errorStyle="color: red" infoStyle="color: white" layout="table"/></td>
</tr>
</table>
</div>
obrigado