VictorArgentin
VictorArgentin

Reputation: 433

Grails controller error

def results = {

    def results = [:]
    def conferences = Conference.list() // lista das conferencias

    String [] conf_origin // array de strings da indexação da classe
    String [] conf_search  = params.conferenceName.split() // array de strings palavras da pesquisa
    boolean test // teste double for

          conferences.each{

                conf_origin = "hi i'm john".split() // indexação
                //conf_origin = "aveiroa".split()
                OUTER: for(int i = 0; i< conf_origin.length; i++){
                            for(int j = 0; j< conf_search.length; j++) {

                                    if(conf_origin[i] == conf_search[j]){
                                        test = true
                                        results.put(it.id, it)
                                        break OUTER;
                                    }
                                }
                            }

                        }

    return [results : results]
}

Hey i am having this problem. If i return: "[conferences: conferences]" my gsp sucessfully do what i want. Altought, when i return '[results: results]' which is suposelly a filtered map of conferences, the folowing error is displayed and i cant figure it out why:

Exception Message: No such property: yearCount for class: java.util.LinkedHashMap$Entry 

PS. Basically, i have

String [] conf_origin ---> which is a String array of words

String [] conf_search ---> which is a string array of introduced words in search bar.

Then i compare both arrays, and if there's one match, i break the for and add that conference object to results.

Upvotes: 1

Views: 937

Answers (1)

Victor Sergienko
Victor Sergienko

Reputation: 13495

conferences is a List (of Conference, but it's untyped in Groovy), and results is a Map. You need either to:

  • make it a List of Conference
  • or return [conferences: results.values()]
  • or adjust your GSP page to iterate over a Map.

Note that conferences is a variable name your GSP code relies onto.

Upvotes: 3

Related Questions