Dialog não chama evento de botão.[RESOLVIDO]

4 respostas
V

Boa noite galera, estou precisando da ajuda de vocês, urgente.
Bom, tenho um index.xhtml que chama outra pagina xhtml e abre apenas o dialog, esse dialog chama outra pagina xhtml e chama outro dialog(rsrs). Então clico no botão salvar e ele simplismente não faz nada. Vou mandar o codigo para vocês.

index.xtml:

<?xml version='1.0' encoding='UTF-8' ?>
<!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:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <title> Sistema Geral</title>
</h:head>
    <h:form>

      <p:menu type="tiered" position="butom" style="width: 180px">
          <p:submenu label="Cadastro" >
              <p:menuitem value="País" onclick="dlgGERSRPAI.show()" />
          </p:submenu>          
      </p:menu>      

      <ui:include src="paginas/GERAL/GERSRPAI.xhtml" />    
        
    </h:form>
</html>

GERSRPAI.xhtml:

<?xml version='1.0' encoding='UTF-8' ?>
<!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:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:composition>
            <ui:include src="GERPRPAI.xhtml" />    
    <h:form id="frmGERSRPAI">
        <p:dialog header="Países cadastrados" widgetVar="dlgGERSRPAI" width="570" height="400" minimizable="true" closable="false" 
                  resizable="false">
            
            <p:commandLink  >
                <p:graphicImage value="/imagens/novo.png"  onclick="dlgGERPRPAI.show()" style="border: none;" update="dlgGERPRPAI"/>
            </p:commandLink> 

            <p:commandLink  >
                        <p:graphicImage value="/imagens/editar.png" style="border: none;"/>
            </p:commandLink> 

            <p:commandLink >
                <p:graphicImage value="/imagens/excluir.png"  style="border: none;"/>
            </p:commandLink> 

            <p:commandLink  >
                <p:graphicImage value="/imagens/relatorio.png" style="border: none;"/>
            </p:commandLink> 

            <p:commandLink  >
                <p:graphicImage value="/imagens/fechar.png" onclick="dlgGERSRPAI.hide()" style="border: none;"/>
            </p:commandLink>

        </p:dialog> 
    </h:form>
    </ui:composition>    

</html>

GERPRPAI.xhtml

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
        <p:dialog header="Países cadastrados" widgetVar="dlgGERPRPAI" width="570" minimizable="true" closable="false" 
                  resizable="false">
			<h:panelGrid columns="1">
				<h:outputText value="Código"/>
				<p:inputText value="#{beanGERTBPAI.GERTBPAI.GER_PK_COD_PAI}" style="width: 50px" disabled="true"/>
				<p:separator style="width: 530px"/> 			
				<h:outputText value="Nome"/>
				<p:inputText value="#{beanGERTBPAI.GERTBPAI.GER_NOME_PAI}"/>
			</h:panelGrid>                   
			<center> 
				<p:commandButton value="Salvar" type="submit" actionListener="#{beanGERTBPAI.salvar}" />
				<p:commandButton value="Cancelar" onclick="dlgGERPRPAI.hide()" /> 
			</center> 			
            
        </p:dialog>                
</html>

Quando abro o ultimo dialog ele não executa o metodo salvar. Por que ?
Abraços.

4 Respostas

T

No teu dialog não tem form!

V

Não funcionou. Eu misturei os dois xhtml, coloquei a tag <h:form> no meu dialog e nada. Vou mostrar o codigo.

GERSRPAI.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!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:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<h:form>      
        <p:dialog header="Países cadastrados" widgetVar="dlgGERSRPAI" width="570" height="400" minimizable="true" closable="false" 
                  resizable="false">            
            <p:commandLink  >
                <p:graphicImage value="/imagens/novo.png"  onclick="dlgGERPRPAI.show()" style="border: none;" update="dlgGERPRPAI"/>
            </p:commandLink> 

            <p:commandLink  >
                        <p:graphicImage value="/imagens/editar.png" style="border: none;"/>
            </p:commandLink> 

            <p:commandLink >
                <p:graphicImage value="/imagens/excluir.png"  style="border: none;"/>
            </p:commandLink> 

            <p:commandLink  >
                <p:graphicImage value="/imagens/relatorio.png" style="border: none;"/>
            </p:commandLink> 

            <p:commandLink  >
                <p:graphicImage value="/imagens/fechar.png" onclick="dlgGERSRPAI.hide()" style="border: none;"/>
            </p:commandLink>
            
        </p:dialog>
        
		<p:dialog header="Países cadastrados" widgetVar="dlgGERPRPAI" width="570" minimizable="true" closable="false" 
		                  resizable="false">
			<h:form>      
			  	<h:panelGrid columns="1">
					<h:outputText value="Código"/>
					<p:inputText value="#{beanGERTBPAI.GERTBPAI.GER_PK_COD_PAI}" style="width: 50px" disabled="true"/>
					<p:separator style="width: 520px"/> 			
					<h:outputText value="Nome"/>
					<p:inputText value="#{beanGERTBPAI.GERTBPAI.GER_NOME_PAI}" style="width: 520px"/>
				</h:panelGrid>                   
					<p:commandButton value="Salvar" type="submit" actionListener="#{beanGERTBPAI.salvar}" />
					<p:commandButton value="Cancelar" actionListener="dlgGERPRPAI.hide()" /> 
			</h:form> 			
		</p:dialog>  
</h:form>		              
         

</html>

Index.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!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:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <title> Sistema Geral</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</h:head>
    <h:form>

      <p:menu type="tiered" position="butom" style="width: 180px">
          <p:submenu label="Cadastro" >
              <p:menuitem value="País" onclick="dlgGERSRPAI.show()" />
          </p:submenu>          
      </p:menu>      

      <ui:include src="paginas/GERAL/GERSRPAI.xhtml" />    
        
    </h:form>
</html>

Quando eu rodo direto o GERSRPAI.xhtml funciona, mas quando eu abro a partir do Index.xhtml não.

T

Ao meu ver, tu precisa ter um form na tela do botão

<h:form>
.
.
.
.
.
<h:commandButton value='Salvar' />

</h:form>
V

Consegui não foi com <h:form> coloquei só o update no commandButton dos campos e funcionou. Obrigado pela atenção. Se alguem quiser o código só dizer. Abraços

Criado 3 de abril de 2012
Ultima resposta 7 de abr. de 2012
Respostas 4
Participantes 2