[2.0] Ebean model class property not displayed in template

169 views
Skip to first unread message

Ólafur Gauti Guðmundsson

unread,
Mar 6, 2012, 9:11:56 PM3/6/12
to play-fr...@googlegroups.com
Hi all,
I created a ticket for this, and attached a Play application which illustrates the problem (https://play.lighthouseapp.com/projects/82401-play-20/tickets/209-ebean-certain-model-class-properties-not-displayed-in-templates). 
But I also wanted to highlight it here, in case other people have encountered this.

Version: Play 2.0-RC3, Java application

I have a model class, which has a @Lob property called "description":

@Lob
public String description;

After persisting to db, and loading from db, I try to display this property in my template:

<p>Description: @myObject.description</p>

But the description is NOT displayed in the template (the result is: <p>Description: </p>).

I then add the following method to my model class:

public String descriptionViaMethodCall() {
    return description;
}

I then use this in the template, and it shows up without problems:

<p>Description: @myObject.descriptionViaMethodCall()</p>

This actually works.

There are other problems as well, for example when displaying properties of objects via @ManyToOne reference.

As I said, I've attached an extremely simple Play app to the ticket which illustrates the problem. 
This is worrying, and I think this needs to be looked into before the final release of Play 2.0.

Thanks!
Best regards,
OGG

Ben McCann

unread,
Mar 6, 2012, 9:34:03 PM3/6/12
to play-fr...@googlegroups.com
Not sure if you've seen it before, but I've been using Project Lombok instead of making my fields public.  You just annotate your class with @Getter and @Setter and it auto-generates all the getters and setters and there Eclipse support for it as well.

GrailsDeveloper

unread,
Mar 7, 2012, 2:33:53 AM3/7/12
to play-fr...@googlegroups.com
I'm not sure but it looks to me that you are using lazy-loading. Perhaps Ebean makes this for Lobs by default.

Niels

Guillaume Bort

unread,
Mar 7, 2012, 4:00:50 AM3/7/12
to play-fr...@googlegroups.com
This issue has been discussed before. You must use private field and
public accessor methods if you want to use Ebean lazy loading (or any
other Java magic) from Scala code.

2012/3/7 Ólafur Gauti Guðmundsson <oli....@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/THqipf7NhH8J.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

--
Guillaume Bort

Ólafur Gauti Guðmundsson

unread,
Mar 7, 2012, 6:15:19 AM3/7/12
to play-fr...@googlegroups.com
Thanks for the reply.
OK, I will do this. It would be great if this sort of trick would be added to the documentation.

Best regards,
OGG

> To post to this group, send email to play-framework@googlegroups.com.


> To unsubscribe from this group, send email to


> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

--
Guillaume Bort

Reply all
Reply to author
Forward
0 new messages