Question

There's an exercise with mortageCalc application at paragraph 3.6.1 in the Griffon in Action book.

Environment:

  • Win 7 Pro, 64-bit
  • IntelliJ IDEA ver 12.1
  • Griffon-1.2.0 JDK 1.6

I have MortgageCalView:

package mortgagecal

application(title:'Mortgage Calculator', pack:true, locationByPlatform:true)
        {
            panel(border: emptyBorder(6)) {
                gridLayout(rows:4, columns:2, hgap:6, vgap:6)
                label('Principal:')
                textField(text: bind(target:model, 'principal',
                        value:'$200,000',
                        validator: model.validatePrincipal,
                        converter: model.convertPrincipal))
                label('Interest Rate:')
                textField(text: bind(target:model, 'monthlyRate',
                        value:'6.5%',
                        validator: model.validateRate,
                        converter: model.convertRate))
                label('Term:')
                textField(text: bind(target:model, 'months',
                        value:'30',
                        validator: model.validateTerm,
                        converter: model.convertTerm))
                label('Monthly Payment (P&I):')
                textField(editable:false,
                        text: bind(source: model, sourceProperty: 'payment',
                                sourceEvent: 'propertyChange',
                                converter: model.convertPayment))
            }
        }

and MortgageCalModel:

package mortgagecal

import groovy.beans.Bindable
import java.text.NumberFormat
import java.text.DecimalFormat

@Bindable
class MortgageCalModel {
    float principal
    float monthlyRate
    float months
    float getPayment() {
        return principal * monthlyRate /
                (1-Math.pow(1/(1+monthlyRate),months))
    }
    private currencyFormat = NumberFormat.currencyInstance
    private percentFormat = new DecimalFormat('0.00%')
    def validatePrincipal = {
        try {
            float principal = currencyFormat.parse(it)
            return principal > 0
        } catch (Exception e) {
            return false
        }
    }
    def convertPrincipal = currencyFormat.&parse
    def validateRate = {
        try {
            float rate = percentFormat.parse(it)
            return rate > 0 && rate < 0.30
        } catch (Exception e) {
            return false
        }
    }
    def convertRate = {
        return percentFormat.parse(it) / 12
    }
    def validateTerm = {
        try {
            def term = Float.parseFloat(it)
            return term > 0 && term < 100
        } catch (Exception e) {
            return false
        }
    }
    def convertTerm = {
        return Float.parseFloat(it) * 12
    }
    def convertPayment = {
        return currencyFormat.format(it)
    }
}

When run it, I see errors:

Caught: groovy.lang.MissingMethodException: No signature of method: mortgagecal.MortgageCalView.application() is applicable for argument types: (java.util.LinkedHashMap, mortgagecal.MortgageCalView$_run_closure1) values: [[title:Mortgage Calculator, pack:true, locationByPlatform:true], ...] groovy.lang.MissingMethodException: No signature of method: mortgagecal.MortgageCalView.application() is applicable for argument types: (java.util.LinkedHashMap, mortgagecal.MortgageCalView$_run_closure1) values: [[title:Mortgage Calculator, pack:true, locationByPlatform:true], ...] at mortgagecal.MortgageCalView.run(MortgageCalView.groovy:3)

But, when I run in command prompt, it works fine:

cd D:\work\griffon\mortgageCal> 
griffon run-app

So, there's smth wrong with my IntelliJ...

Was it helpful?

Solution

Solved! The reason why it was giving an error, because I was trying to run MortgageCalView.groovy. When I run Griffon: mortgageCal it worked. :) In other words: I had to run the project, not a particular script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top