RichFaces - De um DATATABLE para um MODALPANE - perdendo valor

4 respostas
L

Fala galera,
Tudo bem com vocês?

Sempre leio, leio, agora resolvi tirar uma dúvida e pretendo começar a compartilhar meus problemas e soluções com o guj.

- - -

Vamos lá,
meu problema é o seguinte...

Tenho em minha dataTable um commandLink para DELETAR UM CLIENTE que é o responsável por abrir um modalPane que pede a confirmação.
Na confirmação eu queria uma tela personalizada, por exemplo "Deseja excluir o cliente XXXYYY ?" e quando ele clicasse em "CONFIRMAR" fosse enviado pro meu clienteMBean a propriedade NAME (c.name) do ítem selecionado.

O código está logo abaixo mas não consigo resolver esse problema...

PORQUE NÃO ESTOU CONSEGUINDO FAZER ISSO QUE PARECE SER TÃO SIMPLES? HAHA

OBRIGADO PESSOAL! DE CORAÇÃO

<?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: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:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<ui:composition template="templates/templateMain.xhtml">
	<ui:define name="body">
		<h:form>
			<rich:panel id="SumPanel" header="Sumário de clientes">
				<table>
					<tr>
						<td width="300px">
						<table class="filters">
							<thead class="filtersThread">
								<tr class="filters">
									<th colspan="2" class="filters">Filtros</th>
								</tr>
							</thead>
							<tr class="filters">
								<td class="filters">Cliente:</td>
								<td class="filters">#{clientMBean.selectedCustomer}</td>
							</tr>
							<tr class="filters">
								<td class="filters">Categoria:</td>
								<td class="filters">#{clientMBean.customerType}</td>
							</tr>
						</table>
						</td>
						<td>
						<table width="500px" class="summary">
							<thead class="summaryThead">
								<tr class="summary">
									<td class="summary">Total</td>
									<td class="summary">Categoria = Jurídica</td>
									<td class="summary">Categoria = Física</td>
								</tr>
							</thead>
							<tbody>
								<tr class="summary">
									<td class="summary"><h:commandLink id="view"
										action="#{clientMBean.showPageClientList}" event="onclick"
										value="#{clientMBean.customerSum}" reRender="clientListDT">
										<f:param name="paramType" value="-5" />
									</h:commandLink></td>
									<td class="summary"><h:commandLink id="viewJuridico"
										action="#{clientMBean.showPageClientList}" event="onclick"
										value="#{clientMBean.sumCustCorporation}"
										reRender="clientListDT">
										<f:param name="paramType" value="2" />
									</h:commandLink></td>
									<td class="summary"><h:commandLink id="viewFisico"
										action="#{clientMBean.showPageClientList}" event="onclick"
										value="#{clientMBean.sumCustPhysical}" reRender="clientListDT">
										<f:param name="paramType" value="1" />
									</h:commandLink></td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</table>
			</rich:panel>
			<rich:spacer height="10" />
			<rich:panel header="Clientes">
				<rich:messages globalOnly="true" showDetail="true" showSummary="false"
					styleClass="formWarning"
					style="font-size: 10px; font-family:Times New Roman;" />
				<rich:datascroller align="right" for="clientListDT" maxPages="5"
					id="sc1" style=" width : 970px;" />

				<rich:dataTable id="clientListDT" rows="12"
					value="#{clientMBean.clientList}" var="c" reRender="sc1" headerClass="dr-table-headercell"
					styleClass="dataTableDefault" columnClasses="colDefault">

					<rich:column sortBy="#{c.name}" sortOrder="ASCENDING">
						<f:facet name="header">
							<h:outputText value="Nome" />
						</f:facet>
						<h:commandLink id="viewDetail"
							action="#{clientMBean.showPageCustomerDetail}" event="onclick"
							reRender="clientListDT">
							<f:param name="paramCustomer" value="#{c.name}" />
							<h:outputText value="#{c.name}" />
						</h:commandLink>
					</rich:column>
					<rich:column sortBy="#{c.categoryStr}">
						<f:facet name="header">
							<h:outputText value="Categoria" />
						</f:facet>
						<h:outputText value="#{c.categoryStr}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Serviços" />
						</f:facet>
						<h:commandLink id="view1"
							action="#{clientMBean.showPageServiceList}">
							<h:graphicImage value="./image/Icon/viewGraph.png" border="0" />
							<f:param name="paramCustomer" value="#{c.name}" />
						</h:commandLink>
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Ações" />
						</f:facet>
						<h:commandLink id="viewUpdate" value="Alterar"
							action="#{clientMBean.showPageCustomerUpdate}">
							<f:param name="paramCustomer" value="#{c.name}" />
						</h:commandLink>
						<h:outputText value=" | " />
						<a4j:commandLink value="Excluir" id="delete" reRender="delModal"
						onclick="#{rich:component('confirmation')}.show();return false">
							<f:param name="paramTempClient" value="#{c.cpfcnpj}" />
						</a4j:commandLink>
						<h:outputText value=" | " />
						<h:commandLink id="view2" value="Associar CPE"
							action="#{clientMBean.showPageAssociation}">
							<f:param name="paramTempClient" value="#{c.cpfcnpj}" />
						</h:commandLink>
					</rich:column>
				</rich:dataTable>
				<div style="text-align: right; margin-top: 5px"><h:commandButton
					action="#{clientMBean.showPageCustomerAdd}" value="Incluir"
					style=" width : 110px; position: right" /></div>
			</rich:panel>
		</h:form>
		<a4j:form id="delModel">
		          <rich:modalPanel id="confirmation" width="250" height="150">
                <f:facet name="header">Confirmação</f:facet>
                <h:panelGrid>
                    <h:panelGrid columns="1">
                        <h:outputText value="Você tem certeza que deseja excluir o cliente #{c.name}?" />
                    </h:panelGrid>
                    <h:panelGroup>
						<a4j:commandButton action="#{clientMBean.deleteCustomer}"
							value="Excluir" onclick="#{rich:component('confirmation')}.hide();return false" />
                        <input type="button" value="Cancelar"
							onclick="#{rich:component('confirmation')}.hide();return false" />
					</h:panelGroup>
                </h:panelGrid>
            </rich:modalPanel>
		</a4j:form>

	</ui:define>
</ui:composition>
</body>
</html>

4 Respostas

gustavobs

O que retorna ?? Ou não retorna nada ?

L

Quando eu clico no EXCLUIR ele abre o MODAL dizendo

“Você tem certeza que deseja excluir o cliente ?”

mas o código está

“Você tem certeza que deseja excluir o cliente #{c.name}?”

era pra aparecer o nome do cliente também mas não estou conseguindo.

DETALHES:
To usando,
MyFaces
JSF
MBEAN em modo SESSÃO

L

HEL[P]LEASE!

Zenas

Olá Amigo

Modifique o código da seguinte forma

<a4j:commandLink value=“Excluir” id=“delete” reRender=“delModal”
onclick="#{rich:component(‘confirmation’)}.show();return false">

<f:setPropertyActionListener target="#{clientMBean.cliente}" value="#{f}" />

                    </a4j:commandLink>

.
.
.

<a4j:form id=“delModel”>

<rich:modalPanel id=“confirmation” width=“250” height=“150”>

<f:facet name=“header”>Confirmação</f:facet>

<h:panelGrid>

<h:panelGrid columns=“1”>

<h:outputText value=“Você tem certeza que deseja excluir o cliente #{c.name}?” />

</h:panelGrid>

<h:panelGroup>

<a4j:commandButton action="#{clientMBean.deleteCustomer}"

value=“Excluir” onclick="#{rich:component(‘confirmation’)}.hide();return false" >
<f:param id="paramTempClient" name="deletar" value="#{clientMBean.cliente.cpfcnpj}" />

                    </a4j:commandButton >
                    <input type="button" value="Cancelar"   
                        onclick="#{rich:component('confirmation')}.hide();return false" />   
                </h:panelGroup>   
            </h:panelGrid>   
        </rich:modalPanel>   
    </a4j:form>

Espero ter ajudado,

Abraços

Criado 29 de setembro de 2009
Ultima resposta 26 de abr. de 2010
Respostas 4
Participantes 3