Kungen
Kungen

Reputation: 617

For loop in Play Framework, how to get the name of an object

I need help with a for loop in Play Framework.

@for(object <- @Infoobject.show_systemInfoobjects(infoobject.infoobjectId, "sends")) {
   object.designation
}

I get an error saying: "illegal start of simple pattern".

@Infoobject.show_systemInfoobjects(infoobject.infoobjectId, "sends") 

This code snippet returns a list of info objects (List), and I need to loop all the info objects and write out their names.

Any help would be appreciated.

Upvotes: 0

Views: 403

Answers (1)

mguillermin
mguillermin

Reputation: 4181

You should not name things object. That's a reserved word in Scala.

Inside the @for() parentheses you should not use another @, but you will need one to access the inner value inside the {...}.

It will probably work with a code like this one :

@for(info <- Infoobject.show_systemInfoobjects(infoobject.infoobjectId, "sends")) {
    @info.designation
}

Upvotes: 2

Related Questions