java.lang.StackOverflowError
24/09/2013 16:58
package br.com.aplicacao.sanduiche
import java.util.Date;
import java.util.Formatter.DateTime;
class Entregas {
static hasMany = [pedidos:Pedidos]
Enderecos endereco
Funcionario funcionario
Cliente cliente
EstadoEntregaEnum situacaoEntrega
Date dtEntrega
Date dtSolicitacao
double total = 0
static transients = ["total "] //***
static constraints = {
funcionario nullable:false
endereco nullable:true
dtEntrega nullable:true
dtSolicitacao nullable:true
cliente nullable:true
situacaoEntrega nullable:false
}
double getTotal() {
if(pedidos != null){
println pedidos.size();
if(pedidos?.size() >0){
pedidos.each{ it->
println it.total
println "########34##"
println total
total = total + it.total
}
}
}
return total;
}
}
package br.com.aplicacao.sanduiche
import br.com.aplicacao.sanduiche.Produtos
class Pedidos {
Produtos produto
int quantidade = 0
String observacao
double total = 0
static transients = ["total "] //***
static constraints = {
quantidade min:1
produto nullable:false, blank:false
}
double getTotal() {
if(produto==null){
produto = new Produtos(preco:0);
}
return produto.getPreco() * quantidade
}
}
package br.com.aplicacao.sanduiche
import java.util.Date;
import java.util.Formatter.DateTime;
class Entregas {
static hasMany = [pedidos:Pedidos]
Enderecos endereco
Funcionario funcionario
Cliente cliente
EstadoEntregaEnum situacaoEntrega
Date dtEntrega
Date dtSolicitacao
double total = 0
static constraints = {
funcionario nullable:false
endereco nullable:true
dtEntrega nullable:true
dtSolicitacao nullable:true
cliente nullable:true
situacaoEntrega nullable:false
}
double getTotal(){
total=0
if(this.pedidos!=null){
for (ped in this.pedidos){
total = total+ped.getTotal()
}
}
return total
}
}
package br.com.aplicacao.sanduiche
import br.com.aplicacao.sanduiche.Produtos
class Pedidos {
Produtos produto
int quantidade = 0
String observacao
double total = 0
static transients = ["total "] //***
static constraints = {
quantidade min:1
produto nullable:false, blank:false
}
double getTotal() {
if(produto==null){
produto = new Produtos(preco:0);
}
return produto.getPreco() * quantidade
}
}
<g:form method="post" >
<g:hiddenField name="id" value="${entregasInstance?.id}" />
<g:hiddenField name="version" value="${entregasInstance?.version}" />
<fieldset class="form">
<g:render template="form"/>
</fieldset>
<fieldset class="buttons">
<g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" />
<g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" formnovalidate="" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
</fieldset>
</g:form>
Para se registrar, clique aqui.