0 Replies Latest reply on May 15, 2008 3:45 PM by leandro godoy

    Passage of parameters in RichDataTable

    leandro godoy Apprentice

      This table represents an association ternaria where I have a connection request - product - numbering, and I
      specifying pass as the parameter values of a line when the user clicks on a button on the same line,
      How can I pass these values by parameter, there can be no model type model.getRowData (), has to be on the page? Exixte a way to do that?
      Any hint and welcome.
      thank you.


      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <html>
      <head>
      <title></title>
      <link rel="stylesheet" type="text/css"
       href='<%=request.getContextPath() + "/css/tabelas.css" %>'>
      
      </head>
      <script>
       function setFocus (){
       document.getElementById("frm:qtd").focus()
       document.getElementById("frm:qtd").select()
      
       }
      
      function mascara(o,f){
       v_obj=o
       v_fun=f
       setTimeout("execmascara()",1)
      }
      
      function execmascara(){
       v_obj.value=v_fun(v_obj.value)
      }
      
      function leech(v){
       v=v.replace(/o/gi,"0")
       v=v.replace(/i/gi,"1")
       v=v.replace(/z/gi,"2")
       v=v.replace(/e/gi,"3")
       v=v.replace(/a/gi,"4")
       v=v.replace(/s/gi,"5")
       v=v.replace(/t/gi,"7")
       return v
      }
      
      function soNumeros(v){
       return v.replace(/\D/g,"")
      }
      
      
      function telefone(v){
       v=v.replace(/\D/g,"") //Remove tudo o que não é dÃgito
       v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dÃgitos
       v=v.replace(/(\d{4})(\d)/,"$1-$2") //Coloca hÃfen entre o quarto e o quinto dÃgitos
       return v
      }
      
      function cpf(v){
       v=v.replace(/\D/g,"") //Remove tudo o que não é dÃgito
       v=v.replace(/(\d{3})(\d)/,"$1.$2") //Coloca um ponto entre o terceiro e o quarto dÃgitos
       v=v.replace(/(\d{3})(\d)/,"$1.$2") //Coloca um ponto entre o terceiro e o quarto dÃgitos
       //de novo (para o segundo bloco de números)
       v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hÃfen entre o terceiro e o quarto dÃgitos
       return v
      }
      
      function cep(v){
       v=v.replace(/D/g,"") //Remove tudo o que não é dÃgito
       v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
       return v
      }
      
      function cnpj(v){
       v=v.replace(/\D/g,"") //Remove tudo o que não é dÃgito
       v=v.replace(/^(\d{2})(\d)/,"$1.$2") //Coloca ponto entre o segundo e o terceiro dÃgitos
       v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dÃgitos
       v=v.replace(/\.(\d{3})(\d)/,".$1/$2") //Coloca uma barra entre o oitavo e o nono dÃgitos
       v=v.replace(/(\d{4})(\d)/,"$1-$2") //Coloca um hÃfen depois do bloco de quatro dÃgitos
       return v
      }
      
      function romanos(v){
       v=v.toUpperCase() //Maiúsculas
       v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
       //Essa é complicada! Copiei daqui: http://www.diveintopython.org/refactoring/refactoring.html
       while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
       v=v.replace(/.$/,"")
       return v
      }
      
      function site(v){
       //Esse sem comentarios para que você entenda sozinho ;-)
       v=v.replace(/^http:\/\/?/,"")
       dominio=v
       caminho=""
       if(v.indexOf("/")>-1)
       dominio=v.split("/")[0]
       caminho=v.replace(/[^\/]*/,"")
       dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
       caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
       caminho=caminho.replace(/([\?&])=/,"$1")
       if(caminho!="")dominio=dominio.replace(/\.+$/,"")
       v="http://"+dominio+caminho
       return v
      }
      
      </script>
      <body>
      <f:view>
       <a4j:loadScript src="/view/mascaras.js" />
       <f:loadBundle basename="com.Lgweb.Tcc.Model.messages" var="msg" />
      
       <a4j:form id="frm">
       <center>
      
       <c:import url="/view/topo.jsp"></c:import>
       <rich:separator width="1050"></rich:separator>
       <h:panelGrid columns="3" width="800">
       <h:column>
       <c:import url="/view/leftBar.jsp"></c:import>
       </h:column>
       <h:column>
       <rich:panelBar height="580" width="890">
       <rich:panelBarItem label="#{msg.itens}">
       <h:panelGrid columns="3" width="774">
       <h:outputText value="#{msg.cliente}"></h:outputText>
      
       <h:panelGroup>
       <h:selectOneMenu value="#{pedido.pedido.cliente}"required="true"
       requiredMessage="#{msg.obrigatorio}" id="scliente"
       style=" width : 159px;" styleClass="select">
       <f:selectItems value="#{pedido.clienteids}" />
       <f:converter converterId="clienteconversor" />
       </h:selectOneMenu>
      
       <h:commandLink style="cursor:pointer" action="ncliente">
       <h:graphicImage value="/images/arrow_turn_right.png"></h:graphicImage>
       </h:commandLink>
       </h:panelGroup>
       <h:inputHidden value=""></h:inputHidden>
      
       <h:outputText value="#{msg.condicao}"></h:outputText>
       <h:panelGroup>
       <h:selectOneMenu value="#{pedido.pedido.condicaoid}"required="true" requiredMessage="#{msg.obrigatorio}" id="scondicao"
       style=" width : 159px;" styleClass="select">
       <a4j:support event="onchange" action="#{pedido.getParcelas}"
       reRender="np" ajaxSingle="true"></a4j:support>
      
       <f:selectItems value="#{pedido.condicaopagamentoids}" />
       <f:converter converterId="condicaoconversor" />
       </h:selectOneMenu>
       <h:commandLink style="cursor:pointer" action="ncondicao">
       <h:graphicImage value="/images/arrow_turn_right.png"></h:graphicImage>
       </h:commandLink><rich:spacer width="53"></rich:spacer>
       </h:panelGroup>
       <h:inputHidden value=""></h:inputHidden>
      
       <h:outputText value="#{msg.formapagamento}"></h:outputText>
       <h:panelGroup>
       <h:selectOneMenu value="#{pedido.pedido.formapagamento}"required="true" requiredMessage="#{msg.obrigatorio}" id="sforma"
       style=" width : 159px;" styleClass="select">
      
       <f:selectItems value="#{pedido.formapagamentoids}" />
       <f:converter converterId="formaconversor" />
       </h:selectOneMenu>
       <h:commandLink style="cursor:pointer" action="nforma">
       <h:graphicImage value="/images/arrow_turn_right.png"></h:graphicImage>
       </h:commandLink>
       </h:panelGroup>
      
       <h:inputHidden value=""></h:inputHidden>
       <h:outputText value="#{msg.numeroparcela}"></h:outputText>
       <h:inputText value="#{pedido.pedido.numeroparcelas}"
       required="true" id="np" requiredMessage="#{msg.obrigatorio}"
       style=" width : 159px;" styleClass="select" readonly="true"></h:inputText>
       <h:message for="np" styleClass="erro"></h:message>
      
      
      
       <h:outputText value="#{msg.data}"></h:outputText>
       <rich:calendar value="#{pedido.pedido.datavenda}"
       styleClass="select" immediate="true" datePattern="dd/MM/yyyy"
       style=" width : 160px;" popup="true" showInput="true" enableManualInput="true">
      
       </rich:calendar>
       <h:inputHidden value=""></h:inputHidden>
       <h:outputText value="#{msg.usuario}"></h:outputText>
       <h:outputText value="#{pedido.pedido.usuarioid}"></h:outputText>
       </h:panelGrid>
      
       <center>
      
      
       <h:commandButton action="#{pedido.create}"
       value="#{msg.salvar}" type="submit" styleClass="botoes">
       <f:param id="currentUser" value="#{usuario.usuario.login}" name="currentUser" />
      
       </h:commandButton>
       <h:commandButton action="listpedido" value="#{msg.cancelar}"
       styleClass="botoes" immediate="true"></h:commandButton> <h:commandButton
       action="Menu" value="#{msg.menu}" styleClass="botoes"
       immediate="true"></h:commandButton></center>
      
      
       <center>
       <rich:separator width="860"></rich:separator>
       </center>
       <a4j:region id="regiao2">
       <rich:tabPanel switchType="client" id="tabpaneln" title="Itens"
       label="Itens" selectedTab="#{pedido.tabSet}" rendered="#{!pedido.viewState}" immediate="true" style=" width : 844px;">
      
       <rich:tab label="itens" immediate="true" id="tbitens" ajaxSingle="true" >
       <rich:datascroller align="center" for="tbitemvenda"
       maxPages="20" style=" width : 595px;" />
       <rich:dataTable
       onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
       onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
       cellpadding="0" cellspacing="0" rows="5" width="650" border="0"
       var="iv" value="#{pedido.modeliv}" id="tbitemvenda"
       style=" width : 736px;">
       <f:facet name="header">
       <rich:columnGroup>
       <rich:column rowspan="2">
       <h:outputText value="#{msg.acoes}"></h:outputText>
       <rich:separator height="12" styleClass="tooltip"></rich:separator>
      
       <h:commandLink>
       <a4j:support action="#{pedido.novoiv}" event="onclick" reRender="tabpaneln,comboprod,numeros" immediate="true" ></a4j:support>
       <h:graphicImage value="/images/BOTOES/novo1.png" width="20"
       height="20">
       </h:graphicImage>
       </h:commandLink>
       <rich:spacer width="13">
       </rich:spacer>
      
       <h:commandLink id="atualizar" >
       <h:graphicImage value="/images/BOTOES/Restart.png" width="20" height="20">
       </h:graphicImage>
       <a4j:support event="onclick" ajaxSingle="true" reRender="tbitemvenda" action="#{pedido.getTodosItensvenda}" immediate="true"></a4j:support>
       </h:commandLink>
       </rich:column>
       <rich:column colspan="5">
       <h:outputText value="#{msg.itenspedido}"></h:outputText>
       </rich:column>
       <rich:column breakBefore="true">
      
       <h:outputText value="#{msg.produto}" />
      
       </rich:column>
      
       <rich:column>
      
       <h:outputText value="#{msg.qtd}" />
      
       </rich:column>
      
       <rich:column>
      
       <h:outputText value="#{msg.numeracao}" />
      
       </rich:column>
      
       <rich:column>
      
       <h:outputText value="#{msg.valor}" />
      
       </rich:column>
      
       <rich:column>
      
       <h:outputText value="#{msg.valortotal}" />
      
       </rich:column>
      
      
      
       </rich:columnGroup>
      
       </f:facet>
       <rich:column>
       <center>
       <h:commandLink id="editar">
       <a4j:support action="#{pedido.editariv}" ajaxSingle="true" event="onclick" reRender="tabpaneln,comboprod,numeros" immediate="true"></a4j:support>
       <h:graphicImage value="/images/BOTOES/edit.png" width="20"
       height="20">
       </h:graphicImage>
       </h:commandLink>
       <rich:spacer width="13" />
       <h:commandLink id="excluir" action="#{pedido.excluiriv}" >
       <f:param value="#{iv.numeracao}" name="numeracaoparam" />
       <f:param value="#{iv.produto}" name="produtoparam" />
       <a4j:support event="onclick" reRender="vtotal,titens" immediate="true"></a4j:support>
       <h:graphicImage value="/images/BOTOES/Trash2.png" width="20"
       height="20">
       </h:graphicImage>
       </h:commandLink></center>
       </rich:column>
       <rich:column>
       <center>
       <h:outputText value="#{iv.produto}"></h:outputText>
       <f:param value="#{iv.produto}" name="produtoparam" />
       </center>
      
       </rich:column>
       <rich:column>
       <center><h:outputText value="#{iv.quantidade}"></h:outputText>
       </center>
       </rich:column>
       <rich:column>
       <center>
       <h:outputText value="#{iv.numeracao}">
      
       </h:outputText></center>
       </rich:column>
      
       <rich:column>
       <center><h:outputText value="#{iv.valorproduto}">
       <f:convertNumber pattern="R$####.00" />
       </h:outputText></center>
       </rich:column>
      
       <rich:column>
       <center><h:outputText value="#{iv.valortotal}">
       <f:convertNumber pattern="R$####.00" />
       </h:outputText></center>
       </rich:column>
       <f:facet name="footer">
      
      
      
       <rich:columnGroup>
      
       <rich:column>
       <center>
       <h:outputText value="#{msg.total}"> </h:outputText>
       </center>
       </rich:column>
      
       <rich:column >
      
      
      
       </rich:column>
      
       <rich:column>
      
       <h:panelGroup>
       <center>
       <h:outputText value="#{pedido.totalItens}" id="titens" styleClass="erro"></h:outputText>
       <rich:spacer width="10"></rich:spacer>
       <h:outputText value="#{msg.pares}" id="pares"></h:outputText>
       </center>
       </h:panelGroup>
      
       </rich:column>
      
       <rich:column colspan="2">
      
       </rich:column>
      
       <rich:column>
       <center>
       <h:outputText value="#{pedido.pedido.valortotal}" id="vtotal" styleClass="erro">
       <f:convertNumber pattern="R$####.00" />
       </h:outputText>
       </center>
       </rich:column>
      
      
       </rich:columnGroup>
      
       </f:facet>
       </rich:dataTable>
       </rich:tab>
      
       <rich:tab label="Cadastrar" immediate="true" id="tbcad">
       <rich:panelBar height="245" width="712">
       <rich:panelBarItem label="#{msg.pedidos}">
       <h:panelGrid columns="2" width="550">
      
      
       <h:outputText value="#{msg.produto}"></h:outputText>
       <h:panelGroup>
      
       <h:selectOneMenu value="#{pedido.itensvenda.produto}"
       disabled="#{pedido.produtoEditando}" id="comboprod" styleClass="select" onblur="submit();">
       <a4j:support event="onchange" action="#{pedido.habilitaComboNumeracao}" reRender="numeros" ajaxSingle="true">
       </a4j:support>
       <f:selectItems value="#{pedido.produtoids}" />
       <f:converter converterId="produtoconversor" />
       </h:selectOneMenu>
       <h:commandLink style="cursor:pointer" action="nproduto">
       <f:param value="origemPedido" name="origem" id="origem" />
       <h:graphicImage value="/images/arrow_turn_right.png"></h:graphicImage>
       </h:commandLink>
       </h:panelGroup>
      
       <h:outputText value="#{msg.numero}" rendered="#{pedido.produtoSelecionado}" ></h:outputText>
       <h:selectOneMenu
       value="#{pedido.itensvenda.numeracao}" rendered="#{pedido.produtoSelecionado}"
       id="numeros" styleClass="select" style=" width : 158px;" >
       <a4j:support
       event="onblur" action="#{pedido.buscaValorProduto}"
       reRender="valorp" ajaxSingle="true">
       </a4j:support>
       <f:selectItems value="#{pedido.numeracaoids}" />
       <f:converter converterId="numeracaoconversor" />
       </h:selectOneMenu>
      
       <h:outputText value="#{msg.valor}"></h:outputText>
       <h:inputText value="#{pedido.itensvenda.valorproduto}" id="valorp"
       styleClass="select" style=" width : 198px;" readonly="true"></h:inputText>
      
      
      
       <h:outputText value="#{msg.qtd}"></h:outputText>
       <h:panelGroup>
       <h:inputText value="#{pedido.itensvenda.quantidade}"onkeypress="mascara(this,soNumeros)"
       requiredMessage="#{msg.obrigatorio}" styleClass="select" style=" width : 198px;"
       required="true" id="qtd" >
       <a4j:support event="onblur" action="#{pedido.calculaValorTotalProduto}"
       reRender="vt" ajaxSingle="true"></a4j:support>
       </h:inputText>
       <h:message for="qtd" styleClass="erro"></h:message>
       </h:panelGroup>
      
       <h:outputText value="#{msg.valortotal}"></h:outputText>
       <h:inputText value="#{pedido.itensvenda.valortotal}" id="vt"
       styleClass="select" style=" width : 198px;" readonly="true"></h:inputText>
      
       </h:panelGrid>
      
       <center>
       <h:commandButton action="#{pedido.createiv}"
       value="salvar" styleClass="botoes"></h:commandButton>
       <a4j:support event="onclick" reRender="tabpaneln,vtotal,pares,tbitens"></a4j:support>
       <h:commandButton
       action="listitens" value="#{msg.cancelar}"
       styleClass="botoes" immediate="true"></h:commandButton></center>
       </rich:panelBarItem>
       </rich:panelBar>
      
       </rich:tab>
       </rich:tabPanel>
      </a4j:region>
       <div id="novo"><rich:toolTip for="novo" followMouse="true"
       direction="top-right" showDelay="500" styleClass="tooltip">
       <h:outputText value="#{msg.novo}"></h:outputText>
       </rich:toolTip></div>
      
       <div id="atualizar"><rich:toolTip for="atualizar"
       followMouse="true" direction="top-right" showDelay="500"
       styleClass="tooltip">
       <h:outputText value="#{msg.atualizar}"></h:outputText>
       </rich:toolTip></div>
      
      
      
      
       </rich:panelBarItem>
       </rich:panelBar>
       </h:column>
       </h:panelGrid>
      
      
       <c:import url="/view/Statusbar.jsp"></c:import>
       </center>
       </a4j:form>
      </f:view>
      
      
      </body>
      </html>
      
      
      
      


      I'm trying to go well



      
      <h:commandLink id="excluir" action="#{pedido.excluiriv}" >
       <f:param value="#{iv.numeracao}" name="numeracaoparam" />
       <f:param value="#{iv.produto}" name="produtoparam" />
       <a4j:support event="onclick" reRender="vtotal,titens" immediate="true"></a4j:support>
       <h:graphicImage value="/images/BOTOES/Trash2.png" width="20"
       height="20">
       </h:graphicImage>
       </h:commandLink>
      
      

      Thanks.