Problema ao submeter commandButton em rich:popupPanel

1 resposta
S

Olá, pessoal tudo bem?
Estou com um problema em um rich:popupPanel, que ao cicar em um determinado botão nada acontece, nem se quer sai do formulário, sua action principal não funciona.
A ideia é que ao clicar em "editar" em um link possa redirecionar a um determinado modal, este deve conter todos os dados do formulário subsequente e ao inserir novos dados, deveria submetê-lo ao banco, o que não acontece.
Podem ajudar?

dataTable:

<?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:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition template="/template/template.xhtml">
	<ui:define name="corpo">
		<f:view>
			<rich:panel bodyClass="paineis">
				<f:facet name="header">
					<h:outputText value="Consulta de Usuarios"></h:outputText>
				</f:facet>

				<h:panelGrid columns="2">
					<rich:dataTable value="#{usuarioBean.listaUsuarios}"
						var="_usuarios" styleClass="tabelas"
						rowClasses="even-row, odd-row" id="usuariosTable"
						iterationStatusVar="item"
						noDataLabel="Não existem usuarios cadastrados.">

						<rich:column style="width:352px;">
							<f:facet name="header">
								<h:outputText value="Nome" />
							</f:facet>
							<h:outputText value="#{_usuarios.nome}">
							</h:outputText>
						</rich:column>

						<rich:column style="width:352px;">
							<f:facet name="header">
								<h:outputText value="Login" />
							</f:facet>
							<h:outputText value="#{_usuarios.login}">
							</h:outputText>
						</rich:column>

						<rich:column style="width:50px; text-align:center;">
							<f:facet name="header">
								<h:outputText value="Estado" />
							</f:facet>
							<h:selectOneRadio value="#{_usuarios.ativo}" disabled="true">
								<f:selectItem itemValue="true" itemLabel="Ativo"></f:selectItem>
								<f:selectItem itemValue="false" itemLabel="Inativo"></f:selectItem>
							</h:selectOneRadio>
						</rich:column>

						<rich:column style="width:126px; text-align:center;">
							<f:facet name="header">
								<h:outputText value="Ações" />
							</f:facet>

							<a4j:commandLink action="#{usuarioBean.ativar}"
								render="usuariosTable" execute="@this">
								<h:graphicImage library="images"
									name="usuario_ativo_#{_usuarios.ativo}.png" title="Estado"
									styleClass="imagemLink" width="20" height="20" style="border:0" />
								<f:setPropertyActionListener value="#{_usuarios}"
									target="#{usuarioBean.usuarioEdicao}">
								</f:setPropertyActionListener>
							</a4j:commandLink>

							<a4j:commandLink execute="@this" render="modalPanelUsuario"
								oncomplete="#{rich:component('modalPanelUsuario')}.show()">

								<h:graphicImage library="images" name="alterar.png"
									title="Editar" styleClass="imagemLink" width="20" height="20"
									style="border:0" />
								<f:setPropertyActionListener value="#{_usuarios}"
									target="#{usuarioBean.usuarioEdicao}">
								</f:setPropertyActionListener>
							</a4j:commandLink>

							<a4j:commandLink id="linkExcluir" title="Excluir"
								actionListener="#{usuarioBean.editar}">
								<rich:componentControl target="modalPanelExclusaoUsuario"
									operation="show">
								</rich:componentControl>
								<h:graphicImage library="images" name="excluir.png"
									title="Excluir" styleClass="imagemLink" width="20" height="20"
									style="border:0" />
							</a4j:commandLink>

							<rich:popupPanel id="modalPanelExclusaoUsuario" resizeable="true"
								modal="true" width="300" height="110">
								<f:facet name="header">
									<h:outputText value="Confirmação de exclusão" />
								</f:facet>
								<h:outputText value="Deseja realmente excluir o item?" />
								<h:panelGrid columns="2"
									style="margin-left:70px; margin-top:10px;">
									<h:panelGroup>
										<a4j:commandButton value="Cancelar"
											onclick="#{rich:component('modalPanelExclusaoUsuario')}.hide(); return false;">
										</a4j:commandButton>

										<a4j:commandButton value="Excluir" render="usuariosTable"
											execute="@this" action="#{usuarioBean.excluir}"
											immediate="true"
											onclick="#{rich:component('modalPanelExclusaoUsuario')}.hide()">
											<f:setPropertyActionListener value="#{_usuarios}"
												target="#{usuarioBean.usuarioEdicao}">
											</f:setPropertyActionListener>
										</a4j:commandButton>
										<ui:include src="/components/modalPanelUsuario.xhtml" />
									</h:panelGroup>
								</h:panelGrid>
							</rich:popupPanel>
						</rich:column>
					</rich:dataTable>
				</h:panelGrid>
			</rich:panel>
		</f:view>
	</ui:define>
</ui:composition>
</html>
Através deste trecho chamo o popup:
<a4j:commandLink execute="@this" render="modalPanelUsuario"
								oncomplete="#{rich:component('modalPanelUsuario')}.show()">
								<h:graphicImage library="images" name="alterar.png"
									title="Editar" styleClass="imagemLink" width="20" height="20"
									style="border:0" />
								<f:setPropertyActionListener value="#{_usuarios}"
									target="#{usuarioBean.usuarioEdicao}">
								</f:setPropertyActionListener>
							</a4j:commandLink>
Este é o modal:
<?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:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta>
</h:head>

<h:body>
	<f:view>
		<rich:popupPanel id="modalPanelUsuario" modal="false" width="600"
			moveable="false">
			<f:facet name="header">
				<h:outputText value="Editar Usuario"></h:outputText>
			</f:facet>

			<h:panelGrid columns="2">
				<h:form>
					<ui:include src="../formUsuario.xhtml" />
				</h:form>
				<f:facet name="footer">
					<a4j:commandButton value="Cancelar" immediate="true"
						onclick="#{rich:component('modalPanelUsuario')}.hide(); return
false;" />
					<a4j:commandButton actionListener="#{usuarioBean.salvar}"
						value="salvar" render="@form" execute="modalPanelUsuario"
						oncoplete="{#{rich:component('modalPanelUsuario')}.hide();}">
					</a4j:commandButton>
				</f:facet>
			</h:panelGrid>
		</rich:popupPanel>
	</f:view>
</h:body>
</html>
Não sei se é necessário, mas este é o formulário incluso no modal:
<?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:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
<ui:composition>
	<h:panelGrid columns="2">
		<h:outputLabel value="Código:" for="codigo_usu"
			rendered="#{usuarioBean.usuarioEdicao.id !=null}" />
		<h:panelGroup rendered="#{usuarioBean.usuarioEdicao.id !=null}">
			<h:inputText required="true" id="codigo_usu"
				value="#{usuarioBean.usuarioEdicao.id}"
				label="Código do atendimento" disabled="true" />
			<h:message for="codigo_usu" showSummary="true" showDetail="false" />
		</h:panelGroup>


		<h:outputLabel value="Nome" for="nome" />
		<h:panelGroup>
			<h:inputText id="nome" size="40"
				value="#{usuarioBean.usuarioEdicao.nome}" required="true"
				requiredMessage="Este valor é obrigatório"
				onkeyup="this.value = this.value.toUpperCase();" />
			<h:message for="nome" showSummary="true" showDetail="false"
				styleClass="msgErro"></h:message>
		</h:panelGroup>

		<h:outputLabel value="Login" for="login" />
		<h:panelGroup>
			<h:inputText id="login" size="40"
				value="#{usuarioBean.usuarioEdicao.login}" required="true"
				requiredMessage="Este valor é obrigatório"
				onkeyup="this.value = this.value.toUpperCase();" />
			<h:message for="login" showSummary="true" showDetail="false"
				styleClass="msgErro"></h:message>
		</h:panelGroup>

		<h:outputLabel value="Senha" for="senha" />
		<h:panelGroup>
			<h:inputSecret id="senha" size="40"
				value="#{usuarioBean.usuarioEdicao.senha}" required="true"
				requiredMessage="Este valor é obrigatório"
				onkeyup="this.value = this.value.toUpperCase();" />
			<h:message for="senha" showSummary="true" showDetail="false"
				styleClass="msgErro"></h:message>
		</h:panelGroup>

		<h:outputLabel value="Data de nascimento" for="data_nascim" />
		<h:panelGroup>
			<rich:calendar id="data_nascim" enableManualInput="true"
				value="#{usuarioBean.usuarioEdicao.nascimento}" required="true"
				requiredMessage="Este valor é obrigatório" locale="pt_BR"
				datePattern="dd/MM/yyyy" />
			<rich:message for="data_nascim" showSummary="true" showDetail="false"
				styleClass="msgErro" />
		</h:panelGroup>

		<h:outputLabel value="Estado" for="estado" />
		<h:panelGroup>
			<h:selectOneRadio id="estado" required="true"
				requiredMessage="Este valor é obrigatório"
				value="#{usuarioBean.usuarioEdicao.ativo}"
				label="Teste de compatibilidade" layout="pageDirection">
				<f:selectItem itemValue="true" itemLabel="Ativo" />
				<f:selectItem itemValue="false" itemLabel="Inativo" />
			</h:selectOneRadio>
			<h:message for="estado" showSummary="true" showDetail="false"
				styleClass="msgErro">
			</h:message>
		</h:panelGroup>
	</h:panelGrid>
</ui:composition>
</html>
Desde já obrigado.

1 Resposta

kotonet_ga

Cara, estava com o mesmo problema.
Encontrei uma solução neste site: http://garcanjo.blogspot.com.br/2015/06/richpopuppanel-com-commandbutton.html

Basta colocar o atributo domElementAttachment passando o id do form.

Espero ter ajudado

Criado 24 de janeiro de 2013
Ultima resposta 15 de jun. de 2015
Respostas 1
Participantes 2