[Resolvido] rich:modalPanel não atualizava os valores

9 respostas
M

Olá galera td bem?

estou com um problema tenho um rich:modalPanel e nele contem um simples cadastro com nome e data de nascimento e cidade,
mas na hora que vou salvar o atributo está nulo. Já debuguei ele não está fazendo os sets …

o q deve estar acontencendo, ele realmente não faz os sets???

obrigado,

Marcos

9 Respostas

T

posta o codigo

D

Caramba estou com o mesmo problema, tenho uma pagina list e nesta página tenho um botão chamado novo, onde ao clicar-lo abro o modal, preencho os campos e quando vou salvar o hibernate diz que o objeto está nulo.

segue o código:

sexoList.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:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">
	
	<head>
		<link rel="stylesheet" type="text/css" href="css/css-Content.css"/>
		<style>
         .col {
            width:100px;
         }
        </style>
		<title>::: SGE - Sistema Gerenciador de Eventos :::</title>
	</head>
	<f:view>
		<f:loadBundle basename="br.com.edcel.model.messages" var="msg"/>
	<body>
	    <a4j:form id="formList">
		<!--INFORMAÇÃO DO TOPO-->
	        <div id="top-information">
	            <div id="logo">
	                <a href="#"><h:outputLabel value="#{msg.titlePage}"/></a></div>
	            <div id="top-information-home">
	                <a href="Login.html"><h:outputLabel value="#{msg.home}"/></a></div>
	            <div id="top-information-phone">
	                <h:outputLabel value="#{msg.phone}"/></div>
	        </div>
	<!--NAVEGAÇÃO DO TOPO-->
	
	        <div class="none"><a href="#maincontent"></a></div>
	        <div id="nav-main">
				<h:outputLabel rendered="true" value="#{msg.operation}"/><rich:spacer/>
       			<h:outputLabel rendered="true" value="#{msg.financial}"/><rich:spacer/>
       			<h:outputLabel rendered="true" value="#{msg.report}"/><rich:spacer/>
       			<h:outputLabel rendered="true" value="#{msg.administration}"/><rich:spacer/>
	            <div>&nbsp;</div>
	        </div>
	        <a id="maincontent"></a>
	        	        
	<!--BOTOÕES DE AÇÃO-->
	        <div id="pagetitle">
	            <table width="100%" border="0">
	                <tr>
	                    <td align="left" width="90%"><font class="label"><h:outputLabel value="#{msg.titlePageSexo}"/></font></td>
	                    <td align="center"><a href="javascript:Richfaces.showModalPanel('mp',{width:450, top:200});"><font size="2pt"><h:graphicImage url="images/new.png" style="cursor:hand" styleClass="image-border-none"/><br/><h:outputLabel rendered="true" value="#{msg.new}"/></font></a></td>	                    
	                    <td align="right">&nbsp;</td>
	                    <td align="center"><font size="2pt"><h:graphicImage url="images/Print.png" style="cursor:hand" styleClass="image-border-none"/><br/><h:outputLabel rendered="true" value="#{msg.print}"/></font></td>
	                    <td align="right">&nbsp;</td>
	                    <td align="center"><font size="2pt"><h:graphicImage url="images/back.png" style="cursor:hand" styleClass="image-border-none"/><br/><h:outputLabel rendered="true" value="#{msg.back}"/></font></td>
	                    <td align="right">&nbsp;</td>
	                    <td align="center"><font size="2pt"><h:commandLink action="#{sexoBean.Salvar}"><h:graphicImage url="images/accept.png" style="cursor:hand" styleClass="image-border-none"/><h:outputLabel rendered="true" value="#{msg.save}"/></h:commandLink></font></td>
	                    <td align="right">&nbsp;</td>
	                    <td align="center"><font size="2pt"><h:commandLink action="#{sexoBean.Excluir}"><h:graphicImage url="images/delete.png" style="cursor:hand" styleClass="image-border-none"/><h:outputLabel rendered="true" value="#{msg.delete}"/></h:commandLink></font></td>	                    
	                </tr>
	            </table>
	        </div>
	<!--CONTEUDO-->
	        <div id="content-container-three-column">
	            <div id="content-main-three-column">
	            	<rich:panel style="text-align:center;" styleClass="image-border-none">
			            <rich:datascroller align="center"  for="sexoList" maxPages="20" />
			            <rich:spacer height="30" />	            
						<rich:dataTable width="483" id="sexoList" rows="5" columnClasses="col"
							value="#{sexoBean.listaSexo}" var="sexo" sortMode="single" 
							onRowMouseOver="this.style.backgroundColor='#F8F8F8'; this.style.cursor='pointer'"
			               	onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
			
							<f:facet name="header">
								<rich:columnGroup>
									<rich:column>
										<h:outputText styleClass="headerText" value="Id" />
									</rich:column>
									<rich:column>
										<h:outputText styleClass="headerText" value="Descrição" />
									</rich:column>						
								</rich:columnGroup>
							</f:facet>	

							<rich:column id="idSexo" style="text-align:center;">
								<h:outputText value="#{sexo.idSexo}"  />
							</rich:column>
							<rich:column id="descricao" style="text-align:center;">
								<h:outputText value="#{sexo.descricao}" />
							</rich:column>
						</rich:dataTable>
					</rich:panel>	            
	            </div>
	            <div class="clear"></div>
	        </div>
	<!--RODAPÉ-->
	        <div id="footer">
				<h:outputLabel rendered="true" value="#{msg.copyright}"/><a href="LegalNotice.html"><h:outputLabel rendered="true" value="#{msg.termsOfUse}"/></a>	            
	            <div>&nbsp;
	            <br/></div>
	        </div>
	        <div id="footer-sub"></div>
	        <ui:include src="sexoModalForm.xhtml"/>
	    </a4j:form>
	</body>
	</f:view>
</html>

sexoModalForm.xhtml

<ui:composition 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">
			
		<script>
		 function getRightTop(ref) {
		   var position = new Object();
		   position.top = 0; //ref.offsetTop;
		   position.left =0; // ref.offsetLeft+ref.clientWidth+6;
		   return position;
		 }
		</script>
		<style type="text/css">
			.col1 {text-align:right;}
			.col2 {width:60px; text-align:right;}
			.vRow {vertical-align:middle;}
			.rich-message { color:red;	}
		</style>
		
	<f:view>
		<f:loadBundle basename="br.com.edcel.model.messages" var="msg"/>
			<rich:modalPanel  id="mp" minHeight="200" minWidth="450" 
				height="200" width="500" zindex="2000">
				<f:facet name="header">
					<h:outputText value="Modal Panel Title" />
				</f:facet>
				<f:facet name="controls">
					<h:graphicImage value="/images/close.png" style="cursor:pointer" onclick="Richfaces.hideModalPanel('mp')" />
				</f:facet>
				
				<a4j:commandButton oncomplete="Richfaces.hideModalPanel('mp');" action="#{sexoBean.Salvar}" value="#{msg.save}" tabindex="2"/>
				
				<br/>
									
				<rich:separator lineType="dotted" height="1"/>

				<h:panelGrid columns="2">
					<h:outputLabel rendered="true" value="#{msg.code}:"/>
					<h:inputText id="fn1" value="#{sexoBean.sexo.idSexo}" label="#{msg.code}" tabindex="0" styleClass="clsInputField" required="false"/>
					<h:outputLabel rendered="true" value=""/>
					<rich:message  for="fn1" />

					<h:outputLabel rendered="true" value="#{msg.description}:" />
					<h:inputText id="dc1" value="#{sexoBean.sexo.descricao}" label="#{msg.description}" tabindex="1" styleClass="clsInputField" required="true"/>
					<h:outputLabel rendered="true" value=""/>
					<rich:message  for="dc1" />
				</h:panelGrid>
									
				<br/>

			</rich:modalPanel>
	</f:view>
</ui:composition>

managedBean

public class SexoBean {

	private Sexo sexo;
	
	public SexoBean(){
		sexo = new Sexo();
	}
	
	public List<Sexo> getListaSexo()throws DataAccessLayerException{
		return SexoFacade.getInstance().findAll();
	}

	public Sexo getSexo() {
		return sexo;
	}

	public void setSexo(Sexo sexo) {
		this.sexo = sexo;
	}
	
    public String Salvar() throws DataAccessLayerException {
    	SexoFacade.getInstance().save(sexo);
    	return "SUCCESS";
    }
    
    public String Excluir() throws DataAccessLayerException {
    	return "SUCCESS";
    }
}

Obrigado a todos.

D

Este é o erro que o Hibernate retorna, se alguém poder me ajudar…agredeço muito.

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: #{sexoBean.Salvar}: /sexoModalForm.xhtml @34,131 action="#{sexoBean.Salvar}": br.com.edcel.dao.DataAccessLayerException: org.hibernate.PropertyValueException: not-null property references a null or transient value: br.com.edcel.model.Sexo.descricao
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
	org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
	org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
	org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
	org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)

Obrigado.

M

Ainda não consegui resolver o meu problema … os dados não atualizam … ficam nulos … ou quando eu clico no meu dataTable fica akeles dados que veio para sempre jah tentei de tudo … axo q vou desistir!!!

D

Fala galera…tudo bem ???

Alguém sabe o que pode estar ocorrendo ???

Ajuda ae por favor…

M

Por favor me ajudem … tô precisando muito!!!

srá q teria algum problema estou usando o jsf 1.1?

abraços!!

Obrigado!

M

Ai está meu jsp!!!

<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
<%@taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<html>
<head>
<title>Teste</title>
<style type="text/css">
  .botao {
    border-style: none;
    border-right-style: solid;
    border-right-width: 1;
    border-right-color: #3870AF;
    border-bottom-style: solid;
    border-bottom-width: 1;
    border-bottom-color: #3870AF;
	cursor: hand;
    color: #FFFFFF;
    background-color: #336699;
    font-weight: bold;
    font-size: 11px;
    font-family: arial;
    padding: 2px;
    width: 100px;
    _filter: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#3870AF,endColorStr=#59BBFF);
  }
  .botaoTopo {
    width: 3%;
  }
  .tituloTopo {
    font-weight: bold;
    font-style: italic;
    font-size: 16px;
    font-family: arial;
    text-align: right;
  }
  .semMargem {
    margin-top:0px;
    margin-left:0px;
    margin-bottom:0px;
    margin-right:0px;
    padding-top:0px;
    padding-left:0px;
    padding-bottom:0px;
    padding-right:0px;
    border:0px;
  }
  .alinhamentoBottom {
    vertical-align:bottom;
    width:50%;
  }
  .cabecalhoGrid {
    height:40px;
    filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#346ba7,EndColorStr=#51a8e2);
    text-align:center;
    font-family:arial;
    font-size:11px;
    font-weight:bold;
  }
  .linhaGrid {
    height:35px;
    text-align:center;
    font-family:arial;
    font-size:11px;
    width:10%;
  }

  .table{
  	font-family: arial;
  	font-size: 11px;
  	width: 100%;
  	table-layout: fixed;
  }

  .styleOutput{
	font-family:arial;
	font-size:11px;
	font-style: italic;
  }

  .styleInput{
	font-family:arial;
	font-size:11px;
	width:100%;
  }

  .alinhamentoRight{
	text-align: right;
  }

</style>
<script type="text/javascript" src="/teste/cadTeste.js"></script>
</head>

<body background="fundo.jpg" topmargin="0">
<f:view>
	<a4j:form id="cadTeste">

		<rich:panel id="gridMapa" bodyClass="semMargem" headerClass="semMargem" style="background-color:transparent;border:0px;">
			<h:panelGrid columns="1" border="0" cellpadding="0" cellspacing="0" columnClasses="alinhamentoBottom" style="width:100%;">
				<h:column>
					<rich:dataTable columns="4" columnsWidth="70, 10, 10, 10" var="objeto" value="#{testeBean.listaMapaEstrategico}" rowKeyVar="row" cellpadding="0" cellspacing="0" styleClass="table">
						<f:facet name="header">
							<rich:columnGroup>
								<rich:column style="text-align:left;" styleClass="cabecalhoGrid">
									<h:outputText value="Cadastro Teste" />
								</rich:column>
								<rich:column styleClass="cabecalhoGrid">
									<h:outputText value="Fechar" />
								</rich:column>
								<rich:column styleClass="cabecalhoGrid">
									<h:outputText value="Desativar" />
								</rich:column>
								<rich:column styleClass="cabecalhoGrid">
									<h:outputText value="Excluir" />
								</rich:column>
							</rich:columnGroup>
						</f:facet>
						<rich:column style="text-align:left;" styleClass="linhaGrid">
						    <a4j:commandLink reRender="dadosMapa" style="cursor:hand;text-decoration:none;color:black;" oncomplete="abreIframe('cadastroMapa')" >
								<h:outputText value="#{objeto.titulo}" onmouseover="javascript:this.style.textDecoration='underline';"
									    	onmouseout="javascript:this.style.textDecoration='none';" />
								<t:updateActionListener property="#{testeBean.testeObjeto}" value="#{objeto}" />
							</a4j:commandLink>
						</rich:column>
						<rich:column styleClass="linhaGrid">
							<t:selectBooleanCheckbox value="#{objeto.fechado}" onclick="abreConfimacao(this.checked, #{objeto.codigo}, '#{objeto.titulo}', 'fechar', this)" />
						</rich:column>
						<rich:column styleClass="linhaGrid">
							<t:selectBooleanCheckbox value="#{objeto.desativado}" onclick="abreConfimacao(this.checked, #{objeto.codigo}, '#{objeto.titulo}', 'desativar', this)" />
						</rich:column>
						<rich:column styleClass="linhaGrid" >
							<h:graphicImage value="/resources/imagens/fileclose.png" style="cursor:hand;border:0px;" onclick="abreConfimacao(true, #{objeto.codigo}, '#{objeto.titulo}', 'excluir', 0)"/>
						</rich:column>
					</rich:dataTable>
				</h:column>
			</h:panelGrid>
			<h:panelGrid rendered="#{empty testeBean.listaMapaEstrategico}" columns="1" border="0" cellpadding="0" cellspacing="0"
			 		   style="width:100%;vertical-align:middle;height:35px;background-color:#FFFFFF;border:1 1 1 1 solid;border-color:#AAAAAA;">
				<h:column>
					<h:outputLabel value="<< Não há dados para serem exibidos >>"
								style="width:100%;color:#777777;font-family:arial;font-size:11px;text-align:center;"/>
				</h:column>
			</h:panelGrid>
		</rich:panel>

	<!--Iframe de Cadastro-->
		<rich:modalPanel id="cadastroMapa" autosized="true" width="450" height="250">
				<f:facet name="header">
					<h:panelGroup>
						<h:outputLabel value="Nome" style="font-family:arial;font-size:11px;color:#FFFFFF;font-weight:bold;" />
					</h:panelGroup>
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:graphicImage value="/resources/imagens/fechar.gif" title="Fechar" style="cursor:hand;border:0px;" onclick="fechaIframe('cadastroMapa')" />
					</h:panelGroup>
				</f:facet>
					<h:panelGrid id="dadosMapa" columns="1" styleClass="table">
						<h:column>
							<h:outputLabel value="" styleClass="styleOutput" />
						</h:column>
						<h:column>
							<h:inputText value="#{testeBean.testeObjeto.titulo}" styleClass="styleInput" />
						</h:column>
						<h:column>
							<h:outputLabel value="Objetivo" styleClass="styleOutput" />
						</h:column>
						<h:column>
							<h:inputTextarea value="#{testeBean.testeObjeto.objetivo}" onkeypress="maxLengthTextArea(this)" onchange="maxLengthTextArea(this)" style="height:50px" styleClass="styleInput" />
						</h:column>
						<h:column>
							<h:outputLabel value="Período de vigência" styleClass="styleOutput" />
						</h:column>
						<h:column>
							<h:panelGrid columns="4" styleClass="table" columnClasses="alinhamentoRight, , alinhamentoRight, ">
								<h:column>
									<h:outputLabel value="Data de início" styleClass="styleOutput" style="text-align:right;"/>
								</h:column>
								<h:column>
									<rich:calendar value="#{testeBean.testeObjeto.dataInicio}" inputStyle="font-size:10px;height:18px;width:70px;"
									            datePattern="dd/MM/yyyy" locale="pt_BR" showWeeksBar="false" firstWeekDay="0" showApplyButton="false"
									            boundaryDatesMode="select" popup="true" enableManualInput="true" cellWidth="13px" cellHeight="10px"
									            style="font-size:8px;" />
								</h:column>
								<h:column>
									<h:outputLabel value="Data de término" styleClass="styleOutput" style="text-align:right;"/>
								</h:column>
								<h:column>
									<rich:calendar value="#{testeBean.testeObjeto.dataTermino}" showWeeksBar="false" inputStyle="font-size:10px;height:18px;width:70px;"
									            boundaryDatesMode="select" firstWeekDay="0" datePattern="dd/MM/yyyy" locale="pt_BR"
									            showApplyButton="false" enableManualInput="true" popup="true" cellWidth="13px" cellHeight="10px"
									            style="font-size:8px;" />
								</h:column>
							</h:panelGrid>
						</h:column>
					</h:panelGrid>
					<h:panelGrid columns="2" border="0" columnClasses="alinhamentoRight, " styleClass="table">
						<h:column>
							<a4j:commandButton id="salvar" value="Salvar" styleClass="botao" actionListener="#{testeBean.salvarMapa}" bypassUpdates="true" style="display:none" />
							<a4j:commandButton value="Salvar" styleClass="botao" onclick="salvar('cadastroMapa')"/>
						</h:column>
						<h:column>
							<a4j:commandButton value="Cancelar" styleClass="botao" onclick="fechaIframe('cadastroMapa')" />
						</h:column>
					</h:panelGrid>
			</rich:modalPanel>
		<!--Fim do Iframe de Cadastro-->

		<a4j:keepAlive beanName="testeBean" />

	</a4j:form>
</f:view>
</body>
</html>

Me ajudem por favor… ficarei muito GRATO!!!

D

Markinho…consegui meu véio…

veja se o mesmo resolve pra vc…

Vi no seu código que o modal está dentro do form principal.

Eu fiz o seguinte: tirei o modal de dentro do form principal e coloquei logo depois do fechamento da tag Form.

Mudei o tipo do form para <h:form> ao invés de a4j:form.

Depois coloquei um form a4j:form dentro do modal logo antes do meu primeiro panelGrid.

Ai funcionou beleza. Espero que funcione pra vc tambem.

abs.

M

Ae djDufu consegui kara … eh issuh ae mesmo … valeu …

só que no meu caso eu coloquei dois forms a4j (a4j:form)

muito obrigado … fico t devendo essa!!!

abraços kara … boa sorte na sua embreitada!!!

Criado 7 de julho de 2008
Ultima resposta 8 de jul. de 2008
Respostas 9
Participantes 3