Shyam Ramineni
Shyam Ramineni

Reputation: 51

Get BigDecimal value from Grails params

I am writing a reporting functionality for a Domain object in grails. There is field "balance" which is BigDecimal. I am having trouble writing the query. Appreciate any help.

View

<tr class="prop">
<td valign="top" class="name">
<label for="balance"><g:message code="sale.balance.label" default="Balance" /></label>
</td>
<td valign="top" class="value">
<g:textField name="balance" value="${params.balance}" />
</td>
</tr>

Controller

def c = Sale.createCriteria()
def saleList = c.list {
if(params.id)
    idEq(java.lang.Long.parseLong(params.id))
if(params.customerName)
    like('customerName', params.customerName+"%")
if(params.customerPh)
    like('customerPh', params.customerPh+"%")
if(params.balance)
    ge('balance', java.math.BigDecimal(params.balance))
if(params.totalSale)
    ge('totalSale', params.totalSale)

Exception

groovy.lang.MissingPropertyException: No such property: java for class: grails.orm.HibernateCriteriaBuilder at colorthread.SaleController$_closure9_closure23.doCall(SaleController.groovy:289) at colorthread.SaleController$_closure9_closure23.doCall(SaleController.groovy)

Upvotes: 0

Views: 1711

Answers (1)

Lauri Piispanen
Lauri Piispanen

Reputation: 2097

You are missing the new keyword:

    ge('balance', new java.math.BigDecimal(params.balance))

Upvotes: 3

Related Questions