Boa tarde pessoal,
estou com um problema em um popup que estou desenvolvendo e gostaria de saber se alguém pode me ajudar.
tenho uma página simples que chama um popup, o mesmo é aberto corretamente, porém quando clico o botão para listar só é executado quando clico pela segunda vez no botão, após o segundo clique tudo funciona, alguém já passou por isso?
OBS.: o código do handler está bem zoado pq estou apenas efetuando uns testes…
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import com.dexbrasil.dextotal.util.JSFUtils;
import com.dexbrasil.dextotal.util.MensagensUtil;
@ManagedBean
@RequestScoped
public class PessoaById {
private String campo = "pes_nom_completo";
private String digitar;
private List suaLista;
private String dados = "";
private Integer id;
private String erro;
public void pesquisaPessoa() {
if(erro == "" || erro == null) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Campo Obrigatório", "Campo Obrigatório");
FacesContext.getCurrentInstance().addMessage("form", message);
suaLista = new ArrayList();
} else {
suaLista = new ArrayList();
suaLista.add("a3");
suaLista.add("a4");
System.out.println("ERROROROROR: " + getErro());
int tamanho_lista = suaLista.size();
}
}
public void aparece(){
dados = "";
System.out.println("METODO aparece");
System.out.println(JSFUtils.getParameter("cid"));
setDados((String)JSFUtils.getParameter("cid"));
}
public String getCampo() {
return campo;
}
public void setCampo(String campo) {
this.campo = campo;
}
public String getDigitar() {
return digitar;
}
public void setDigitar(String digitar) {
this.digitar = digitar;
}
public List getSuaLista() {
return suaLista;
}
public void setSuaLista(List suaLista) {
this.suaLista = suaLista;
}
public String getDados() {
return dados;
}
public void setDados(String dados) {
this.dados = dados;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getErro() {
return erro;
}
public void setErro(String erro) {
this.erro = erro;
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:t="http://myfaces.apache.org/tomahawk">
<h:head>
</h:head>
<h:body>
<h:form id="Formulario">
<t:saveState value="#{pessoaById}" />
<h:inputText value="#{pessoaById.digitar}" />
<a4j:commandButton id="pesquisar" render="popupColaboradores" value="Pesquisa com popup" oncomplete="#{rich:component('popupColaboradores')}.show();" />
<h:commandButton value="aparece" action="#{pessoaById.aparece}" />
</h:form>
<br/><br/>
<rich:tabPanel id="panel" switchType="client">
<rich:tab header="Dados Pessoais">
#{pessoaById.dados}
<br/>
</rich:tab>
<rich:tab header="Cursos">
<p>We are working hard on RichFaces 4.0 which will have full JSF
2 integration. That is not all though, here is a summary of updates
and features:</p>
</rich:tab>
</rich:tabPanel>
<br/>
<br/>
<!-- ModalPanel, inicio -->
<rich:popupPanel id="popupColaboradores" resizeable="true" height="250" width="600">
<f:facet name="header">
<h:outputText value="Selecione o colaborador"/>
</f:facet>
<f:facet name="controls">
<h:outputLink value="#" onclick="#{rich:component('popupColaboradores')}.hide();">
X
</h:outputLink>
</f:facet>
<h:panelGrid columns="2">
<h:outputText value="Colaboradores:"/>
<center>
<h:form id="fds">
<a4j:region>
<h:inputText id="campo" value="#{pessoaById.erro}" />
<a4j:commandButton value="procurar" render="testetable" action="#{pessoaById.pesquisaPessoa}" />
<h:dataTable border="1" id="testetable" var="u" value="#{pessoaById.suaLista}">
<h:column>
<f:facet name="header">
<h:outputText value="id" />
</f:facet>
<h:outputText value="#{u}" />
</h:column>
<h:column>
<a4j:commandLink value="Adicionar" render="panel" action="#{pessoaById.aparece}" onclick="#{rich:component('popupColaboradores')}.hide();">
<f:param name="cid" value="#{u}"/>
</a4j:commandLink>
</h:column>
</h:dataTable>
<rich:messages />
</a4j:region>
</h:form>
</center>
</h:panelGrid>
</rich:popupPanel>
</h:body>
</html>