Modal fecha sozinho

2 respostas
F

Boa tarde galera… Eu tenho um modalpanel e quando eu clico em qualquer botao que esteja dentro dele, ele fecha automatica. Isso nao pode acontecer. Segue o codigo do 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>
<head>
<title>SM2 - SOLUÇÃO MÓVEL DE MANUTENÇÃO - WEB</title>
<link rel="StyleSheet" type="text/css"
	href="${pageContext.request.contextPath}/style.css" />
</head>
<body>
<ui:composition 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:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">
	<f:view>
		<rich:modalPanel id="panel" autosized="false" width="800" height="600">

			<f:facet name="header">
				<h:panelGroup>
					<h:outputText value="Pesquisa Departamento" />
				</h:panelGroup>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close.png" id="hidelink"
						title="Close" />
					<rich:componentControl for="panel" attachTo="hidelink"
						operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<a4j:form id="formModal">
				<h:commandLink id="btnPesq" title="Pesquisar"
					action="#{pesquisaDepartment.pesquisar}">

					<h:graphicImage id="imagePesq" url="/images/lupa.png" width="20"
						height="20" style="border:0" />
				</h:commandLink>

				<rich:spacer width="10" />

				<h:commandLink id="btnOK" title="OK">
					<h:graphicImage id="imageOK" url="/images/ok.jpg" style="border:0"
						width="20" height="20" />
				</h:commandLink>

				<rich:spacer height="15" width="100%" />

				<rich:panel header="Parametros para Seleção" style="height:200"
					width="760">
					<h:panelGrid columns="7">
						<h:outputText value="Campo: " />

						<h:selectOneMenu value="#{pesquisaDepartment.criterion.field}"
							style="width:150">
							<f:selectItem itemLabel="" itemValue="" />
							<f:selectItem itemLabel="Codigo" itemValue="departmentCode" />
							<f:selectItem itemLabel="Descrição" itemValue="departmentName" />
						</h:selectOneMenu>

						<h:outputText value="Condição: " />

						<h:selectOneMenu id="cmbCondicao"
							value="#{pesquisaDepartment.criterion.condition}"
							style="width:150">
							<f:selectItem itemLabel="" itemValue="" />
							<f:selectItem itemLabel="Igual" itemValue="igual" />
							<f:selectItem itemLabel="Parecido" itemValue="parecido" />
							<f:selectItem itemLabel="Diferente" itemValue="diferente" />
							<f:selectItem itemLabel="Começa com" itemValue="comecaCom" />
							<f:selectItem itemLabel="Termina com" itemValue="terminaCom" />
							<f:selectItem itemLabel="Maior que" itemValue="maiorQue" />
							<f:selectItem itemLabel="Menor que" itemValue="menorQue" />
						</h:selectOneMenu>

						<h:outputText value="Valor: " />

						<h:inputText style="width:200"
							value="#{pesquisaDepartment.criterion.value}" />

						<h:commandLink id="btnAddParametro" title="Adicionar Criterio"
							action="#{pesquisaDepartment.addCriterion}">
							<h:graphicImage id="imageAddParametro" url="/images/mais.png"
								style="border:0" />
						</h:commandLink>
					</h:panelGrid>

					<rich:spacer height="30" width="100%" />

					<rich:dataTable id="table" columns="3" width="760"
						value="#{pesquisaDepartment.dtCriterions}" var="list">
						<f:facet name="header">
							<rich:columnGroup>
								<rich:column id="campo">
									<h:outputText value="Campo" />
								</rich:column>
								<rich:column id="condicao">
									<h:outputText value="Condição" />
								</rich:column>
								<rich:column id="value">
									<h:outputText value="Valor" />
								</rich:column>
								<rich:column id="controle">
								</rich:column>
							</rich:columnGroup>
						</f:facet>
						<h:column>
							<h:outputText value="#{list.field}" />
						</h:column>
						<h:column>
							<h:outputText value="#{list.condition}" />
						</h:column>
						<h:column>
							<h:outputText value="#{list.value}" />
						</h:column>
						<h:column>
							<h:commandLink id="btnExcluirParametro"
								title="Excluir Criterio"
								action="#{pesquisaDepartment.deleteCriterion}">
								<h:graphicImage id="imageExluir" url="/images/delete.png"
									style="border:0" />
							</h:commandLink>
						</h:column>
					</rich:dataTable>
				</rich:panel>
				<rich:spacer width="100%" height="15" />

				<rich:dataTable width="99%" style="text-align:center"
					value="#{pesquisaDepartment.dtModel}" var="dt" rows="10"
					reRender="ds" id="simpletable"
					onRowMouseOver="this.style.backgroundColor='#F5E9D3'"
					onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
					<f:facet name="header">
						<rich:columnGroup>
							<rich:column>
								<h:outputText value="Código Departamento" />
							</rich:column>
							<rich:column>
								<h:outputText value="Descrição" />
							</rich:column>
						</rich:columnGroup>
					</f:facet>
					<rich:column>						
						<h:outputText value="#{dt.departmentCode}" />
					</rich:column>
					<rich:column>						
						<h:outputText value="#{dt.departmentName}" />
					</rich:column>
					<f:facet name="footer">
						<rich:datascroller id="ds" renderIfSinglePage="false"></rich:datascroller>
					</f:facet>
				</rich:dataTable>
			</a4j:form>
		</rich:modalPanel>
	</f:view>
</ui:composition>
</body>
</html>

Alguem poderia me auxiliar nessa duvida? Desde já agradeço.

Abraços…

2 Respostas

T

Ao invés de:

h:commandLink

Use:

a4j:commandLink
F

Bom dia Thiagowig. Obrigado pela ajuda cara.
Seguinte,
eu tava usando o a4j:commanLink em todo meu modal e quando eu clicava no link e executava o metodo, todos os meus atributos do bean estavam vazios. Entao eu tentei utilizar o h:commandLink para tentar sanar o problema dos atributos nulos no bean. Solucionei o problema dos atributos e ganhei o problema do modal fechar sozinho. rs

Consegui resolver da seguinte forma: Na verdade eu tava vacilando pq eu coloquei a variavel do <a4j:commandLink ajaxSingle=“true” ai entao o formulario nao dava o post para setar os valores no beam. Apos achar esse erro, testei e ficou tudo correto.

Muito obrigado pela ajuda ai. Fica a dica e vou deixar tb o codigo do Modal para alguem precisar um dia.

<?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>
<head>
<title>SM2 - SOLUÇÃO MÓVEL DE MANUTENÇÃO - WEB</title>
<link rel="StyleSheet" type="text/css"
	href="${pageContext.request.contextPath}/style.css" />
</head>
<body>
<ui:composition 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:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">
	<f:view>
		<rich:modalPanel id="panel" autosized="false" width="800" height="600">

			<f:facet name="header">
				<h:panelGroup>
					<h:outputText value="Pesquisa Departamento" />
				</h:panelGroup>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close.png" id="hidelink"
						title="Close" />
					<rich:componentControl for="panel" attachTo="hidelink"
						operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<a4j:form id="formModal">
				<a4j:commandLink id="btnPesq" title="Pesquisar"
					action="#{pesquisaDepartment.pesquisar}" reRender="simpletable">
					<h:graphicImage id="imagePesq" url="/images/lupa.png" width="20"
						height="20" style="border:0" />
				</a4j:commandLink>

				<rich:spacer width="10" />

				<a4j:commandLink id="btnOK" title="OK">
					<h:graphicImage id="imageOK" url="/images/ok.jpg" style="border:0"
						width="20" height="20" />
				</a4j:commandLink>

				<rich:spacer height="15" width="100%" />

				<rich:panel header="Parametros para Seleção" style="height:200"
					width="760">
					<h:panelGrid columns="7">
						<h:outputText value="Campo: " />

						<h:selectOneMenu value="#{pesquisaDepartment.criterion.field}"
							style="width:150">
							<f:selectItem itemLabel="" itemValue="" />
							<f:selectItem itemLabel="Codigo" itemValue="departmentCode" />
							<f:selectItem itemLabel="Descrição" itemValue="departmentName" />
						</h:selectOneMenu>

						<h:outputText value="Condição: " />

						<h:selectOneMenu id="cmbCondicao"
							value="#{pesquisaDepartment.criterion.condition}"
							style="width:150">
							<f:selectItem itemLabel="" itemValue="" />
							<f:selectItem itemLabel="Igual" itemValue="igual" />
							<f:selectItem itemLabel="Parecido" itemValue="parecido" />
							<f:selectItem itemLabel="Diferente" itemValue="diferente" />
							<f:selectItem itemLabel="Começa com" itemValue="comecaCom" />
							<f:selectItem itemLabel="Termina com" itemValue="terminaCom" />
							<f:selectItem itemLabel="Maior que" itemValue="maiorQue" />
							<f:selectItem itemLabel="Menor que" itemValue="menorQue" />
						</h:selectOneMenu>

						<h:outputText value="Valor: " />

						<h:inputText style="width:200"
							value="#{pesquisaDepartment.criterion.value}" />

						<a4j:commandLink id="btnAddParametro" title="Adicionar Criterio"
							action="#{pesquisaDepartment.addCriterion}" reRender="table">
							<h:graphicImage id="imageAddParametro" url="/images/mais.png"
								style="border:0" />
						</a4j:commandLink>
					</h:panelGrid>

					<rich:spacer height="30" width="100%" />

					<rich:dataTable id="table" columns="3" width="760"
						value="#{pesquisaDepartment.dtCriterions}" var="list">
						<f:facet name="header">
							<rich:columnGroup>
								<rich:column id="campo">
									<h:outputText value="Campo" />
								</rich:column>
								<rich:column id="condicao">
									<h:outputText value="Condição" />
								</rich:column>
								<rich:column id="value">
									<h:outputText value="Valor" />
								</rich:column>
								<rich:column id="controle">
								</rich:column>
							</rich:columnGroup>
						</f:facet>
						<h:column>
							<h:outputText value="#{list.field}" />
						</h:column>
						<h:column>
							<h:outputText value="#{list.condition}" />
						</h:column>
						<h:column>
							<h:outputText value="#{list.value}" />
						</h:column>
						<h:column>
							<h:commandLink id="btnExcluirParametro"
								title="Excluir Criterio"
								action="#{pesquisaDepartment.deleteCriterion}">
								<h:graphicImage id="imageExluir" url="/images/delete.png"
									style="border:0" />
							</h:commandLink>
						</h:column>
					</rich:dataTable>
				</rich:panel>
				<rich:spacer width="100%" height="15" />

				<rich:dataTable width="99%" style="text-align:center"
					value="#{pesquisaDepartment.dtModel}" var="dt" rows="10"
					reRender="ds" id="simpletable"
					onRowMouseOver="this.style.backgroundColor='#F5E9D3'"
					onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
					<f:facet name="header">
						<rich:columnGroup>
							<rich:column>
								<h:outputText value="Código Departamento" />
							</rich:column>
							<rich:column>
								<h:outputText value="Descrição" />
							</rich:column>
						</rich:columnGroup>
					</f:facet>
					<rich:column>						
						<h:outputText value="#{dt.departmentCode}" />
					</rich:column>
					<rich:column>						
						<h:outputText value="#{dt.departmentName}" />
					</rich:column>
					<f:facet name="footer">
						<rich:datascroller id="ds" renderIfSinglePage="false"></rich:datascroller>
					</f:facet>
				</rich:dataTable>
			</a4j:form>
		</rich:modalPanel>
	</f:view>
</ui:composition>
</body>
</html>
Criado 15 de junho de 2010
Ultima resposta 16 de jun. de 2010
Respostas 2
Participantes 2