Erro na constrant inList , no Grails 1.0.4
04/12/2008 00:00
0
Pessoal,
a constraint inList esta causando erro ao tentar acessar a url, compila mas quando se tenta acessar a url \create aparece um erro NullPointException
mas na versão 1.0.3 funciona.

alguém sabe oque esta acontecendo?
Segue o código:

static def constraints =
{
tipoPedido(inList:["Pre_venda", "Carga"], maxSize:10) //se comentar esta linha funciona!
dataEmissao(blank: false)
pedidoCompra(maxSize: 20)
comprador(maxSize: 20)
}
Tags: Grails


0
93!

Testei e funcionou normalmente...
Posta o erro aí!

[]'s

93,93/93
05/12/2008 00:00


0
Este é o erro que aparece no browser + os codigos do controller e da view.
Outra coisa eu tinha iniciado a aplicaçao no 1.0.3 e usei o comando upgrade para o 1.0.4

Um abraço,
Evandro


Grails Runtime Exception
Error Details
Message:
Caused by:
Class: Unknown
At Line: [-1]
Code Snippet:
Stack Trace

java.lang.NullPointerException

at C__Documents_20and_20Settings_Evandro_ir_workspace_renovapam_grails_app_views_conta_create_gsp$_run_closure7.doCall(C__Documents_20and_20Settings_Evandro_ir_workspace_renovapam_grails_app_views_conta_create_gsp:64)

at C__Documents_20and_20Settings_Evandro_ir_workspace_renovapam_grails_app_views_conta_create_gsp$_run_closure7.doCall(C__Documents_20and_20Settings_Evandro_ir_workspace_renovapam_grails_app_views_conta_create_gsp)

at C__Documents_20and_20Settings_Evandro_ir_workspace_renovapam_grails_app_views_conta_create_gsp.run(C__Documents_20and_20Settings_Evandro_ir_workspace_renovapam_grails_app_views_conta_create_gsp:90)


O fonte do controller:

class ContaController {

def index = { redirect(action:list,params:params) }

// the delete, save and update actions only accept POST requests
def allowedMethods = [delete:'POST', save:'POST', update:'POST']

def list = {
if(!params.max) params.max = 10
[ contaInstanceList: Conta.list( params ) ]
}

def show = {
def contaInstance = Conta.get( params.id )

if(!contaInstance) {
flash.message = "contaInstance.not.found"
flash.args = [params.id]
flash.defaultMessage = "Conta not found with id ${params.id}"
redirect(action:list)
}
else { return [ contaInstance : contaInstance ] }
}

def delete = {
def contaInstance = Conta.get( params.id )
if(contaInstance) {
contaInstance.delete()
flash.message = "contaInstance.deleted"
flash.args = [params.id]
flash.defaultMessage = "Conta ${params.id} deleted"
redirect(action:list)
}
else {
flash.message = "contaInstance.not.found"
flash.args = [params.id]
flash.defaultMessage = "Conta not found with id ${params.id}"
redirect(action:list)
}
}

def edit = {
def contaInstance = Conta.get( params.id )

if(!contaInstance) {
flash.message = "contaInstance.not.found"
flash.args = [params.id]
flash.defaultMessage = "Conta not found with id ${params.id}"
redirect(action:list)
}
else {
return [ contaInstance : contaInstance ]
}
}

def update = {
def contaInstance = Conta.get( params.id )
if(contaInstance) {
contaInstance.properties = params
if(!contaInstance.hasErrors() && contaInstance.save()) {
flash.message = "contaInstance.updated"
flash.args = [params.id]
flash.defaultMessage = "Conta ${params.id} updated"
redirect(action:show,id:contaInstance.id)
}
else {
render(view:'edit',model:[contaInstance:contaInstance])
}
}
else {
flash.message = "contaInstance.not.found"
flash.args = [params.id]
flash.defaultMessage = "Conta not found with id ${params.id}"
redirect(action:edit,id:params.id)
}
}

def create = {
def contaInstance = new Conta()
contaInstance.properties = params
return ['contaInstance':contaInstance]
}

def save = {
def contaInstance = new Conta(params)
if(!contaInstance.hasErrors() && contaInstance.save()) {
flash.message = "contaInstance.created"
flash.args = ["${contaInstance.id}"]
flash.defaultMessage = "Conta ${contaInstance.id} created"
redirect(action:show,id:contaInstance.id)
}
else {
render(view:'create',model:[contaInstance:contaInstance])
}
}
}




O fonte da view:

<html>
<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;/>
<meta name=&quot;layout&quot; content=&quot;main&quot; />
<title><g:message code=&quot;contaInstance.create&quot; default=&quot;Create Conta&quot; /></title>
</head>
<body>
<div class=&quot;nav&quot;>
<span class=&quot;menuButton&quot;><a class=&quot;home&quot; href=&quot;${createLinkTo(dir:'')}&quot;><g:message code=&quot;home&quot; default=&quot;Home&quot; /></a></span>
<span class=&quot;menuButton&quot;><g:link class=&quot;list&quot; action=&quot;list&quot;><g:message code=&quot;contaInstance.list&quot; default=&quot;Conta List&quot; /></g:link></span>
</div>
<div class=&quot;body&quot;>
<h1><g:message code=&quot;contaInstance.create&quot; default=&quot;Create Conta&quot; /></h1>
<g:if test=&quot;${flash.message}&quot;>
<div class=&quot;message&quot;><g:message code=&quot;${flash.message}&quot; args=&quot;${flash.args}&quot; default=&quot;${flash.defaultMessage}&quot; /></div>
</g:if>
<g:hasErrors bean=&quot;${contaInstance}&quot;>
<div class=&quot;errors&quot;>
<g:renderErrors bean=&quot;${contaInstance}&quot; as=&quot;list&quot; />
</div>
</g:hasErrors>
<g:form action=&quot;save&quot; method=&quot;post&quot; >
<div class=&quot;dialog&quot;>
<table>
<tbody>

<tr class=&quot;prop&quot;>
<td valign=&quot;top&quot; class=&quot;name&quot;>
<label for=&quot;tipoConta&quot;><g:message code=&quot;contaInstance.tipoConta&quot; default=&quot;Tipo Conta&quot; />:</label>
</td>
<td valign=&quot;top&quot; class=&quot;value ${hasErrors(bean:conta,field:'tipoConta','errors')}&quot;>
<g:select id=&quot;tipoConta&quot; name=&quot;tipoConta&quot; from=&quot;${conta.constraints.tipoConta.inList}&quot; value=&quot;${conta.tipoConta}&quot; valueMessagePrefix=&quot;conta.tipoConta&quot; ></g:select>
</td>
</tr>

<tr class=&quot;prop&quot;>
<td valign=&quot;top&quot; class=&quot;name&quot;>
<label for=&quot;nome&quot;><g:message code=&quot;contaInstance.nome&quot; default=&quot;Nome&quot; />:</label>
</td>
<td valign=&quot;top&quot; class=&quot;value ${hasErrors(bean:conta,field:'nome','errors')}&quot;>
<input type=&quot;text&quot; maxlength=&quot;30&quot; id=&quot;nome&quot; name=&quot;nome&quot; value=&quot;${fieldValue(bean:conta,field:'nome')}&quot;/>
</td>
</tr>

<tr class=&quot;prop&quot;>
<td valign=&quot;top&quot; class=&quot;name&quot;>
<label for=&quot;descricao&quot;><g:message code=&quot;contaInstance.descricao&quot; default=&quot;Descricao&quot; />:</label>
</td>
<td valign=&quot;top&quot; class=&quot;value ${hasErrors(bean:conta,field:'descricao','errors')}&quot;>
<input type=&quot;text&quot; maxlength=&quot;80&quot; id=&quot;descricao&quot; name=&quot;descricao&quot; value=&quot;${fieldValue(bean:conta,field:'descricao')}&quot;/>
</td>
</tr>

</tbody>
</table>
</div>
<div class=&quot;buttons&quot;>
<span class=&quot;button&quot;><input class=&quot;save&quot; type=&quot;submit&quot; value=&quot;${message(code:'create', 'default':'Create')}&quot; /></span>
</div>
</g:form>
</div>
</body>
</html>
08/12/2008 00:00


0
Pessoal,

reparei que ao começar um novo projeto no grails 1.0.4 este problema não ocorre, porém o projeto acima em certo momento eu fiz o upgrade
da 1.0.3 para a 1.0.4

será que o problema esta ai?

Valeu!
Evandro
08/12/2008 00:00



Ainda não faz parte da comunidade???

Para se registrar, clique aqui.


Aprenda Groovy e Grails com a Formação itexto!

Newsletter Semana Groovy

Assinar

Envie seu link!


Livro de Grails


/dev/All

Os melhores blogs de TI (e em português) em um único lugar!

 
Creative Commons
RSS Grails Brasil é mantido por itexto Consultoria.
Em caso de problemas contacte Henrique Lobo Weissmann (Kico) por e-mail: kico@itexto.com.br
Todo o conteúdo presente neste site adota o Creative Commons como licença padrão.
Ver: 4.14.0
itexto