scala - How to acces nested model's attributes in Play 2 templates -


i've got 2 models in play 2 project :

@entity public class site extends model{      @id     public string adid;      @required     public string name;      @required     @onetomany (cascade = cascadetype.all)     public list<room> rooms; ... }//end of class 

and

@entity public class room extends model {      @id     @required     public string adid;      @required      public string name;      public list<reservation> reservations = new arraylist<reservation>();  ... } 

when use code in view.scala.html

            var treedata = [                                                 @for(site <- sites) {                         {title: "@site.name", tooltip: "@site.adid",                             children: [                                 @for(room <- site.rooms) {                                     {title: "@room.name", tooltip: "@room.adid"},                                 }                             ]                         },                     }                 ]; 

i can't acces site.rooms if test on server side, data exist.

another strange thing site.adid, site.name stays empty...

if knows i'm doing wrong...

(sorry poor english, it's not mother language).

you need getters data accessible in templates / scala. @ least fixed me. think found information on mailinglist:

this issue has been discussed before. must use private field , public accessor methods if want use ebean lazy loading (or other java magic) scala code.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -