Overwriting the CRUD/list - question

79 views
Skip to first unread message

Tom du Plessis

unread,
Sep 24, 2010, 7:57:21 AM9/24/10
to play-framework
Howdy folks
I've only spent a short while learning to Play! so pls forgive me if
this is a silly question.

I have a model called Team and a Controller called Teams that looks
like this:

----Teams.java:---
package controllers;

public class Teams extends CRUD {

}
--------

I have overwritten the Teams/list template and left it unchanged for
now. My intention is to build a filter into the Teams list view to
filter Teams by League (there is a 1toMany relationship between Team
and League). So I started by creating the Teams.list() action as
such, intending to build the filter in at a later stage:

public static void list() {
List<Team> teams = Team.findAll();
render(teams);
}

However that gives me an NPE. I can confirm that Team.findAll() does
return some objects.
Even just a simple

public static void list() {
render();
}

gives me the NPE.

What am I doing wrong?

Julien Tournay

unread,
Sep 24, 2010, 9:45:56 AM9/24/10
to play-fr...@googlegroups.com

Could you send the stacktrace ?

jto.


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
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.




--
Real Programmers don't need comments-- the code is obvious.

GrailsDeveloper

unread,
Sep 24, 2010, 9:59:46 AM9/24/10
to play-framework
The Play-version and stacktrace would be a good additional
information.
Niels

Guillaume Bort

unread,
Sep 25, 2010, 7:50:32 AM9/25/10
to play-fr...@googlegroups.com
The default template will search for an 'objects' property. Try to
rename teams to objects.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> 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, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

Tom du Plessis

unread,
Sep 29, 2010, 3:48:13 AM9/29/10
to play-framework
Hi guys, thanks for those quick responses. @Guillaume, I have
replaced teams with 'objects' as such:

public static void list() {
List<Team> objects = Team.findAll();
render(objects);
}

...afraid that didn't work. The stack trace is here:


Internal Server Error (500) for request GET /teams/list

Template execution error (In {module:crud}/app/views/tags/crud/
pagination.html around line 1)
Execution error occured in template {module:crud}/app/views/tags/crud/
pagination.html. Exception raised was NullPointerException : null.

play.exceptions.TemplateExecutionException
at play.templates.Template.throwException(Template.java:296)
at play.templates.Template.render(Template.java:261)
at play.templates.Template$ExecutableTemplate.invokeTag(Template.java:
394)
at /app/views/Teams/list.html.(line:16)
at play.templates.Template.render(Template.java:238)
at play.mvc.results.RenderTemplate.<init>(RenderTemplate.java:22)
at play.mvc.Controller.renderTemplate(Controller.java:489)
at play.mvc.Controller.render(Controller.java:521)
at controllers.Teams.list(Teams.java:11)
at play.utils.Java.invokeStatic(Java.java:129)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:139)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
at {module:crud}/app/views/tags/crud/pagination.html.(line:1)
at play.templates.Template.render(Template.java:238)
... 10 more

I'm using Play! 1.0.3.2 with JDK 6u21 and the bundled memdb.

I have not been able to find any documentation regarding overwriting
or extending CRUD/list. If someone can point me to it I would be very
grateful. If there is non, I'd be happy to contribute one, assuming I
get to figure this out :)

Regards
Tommo
Reply all
Reply to author
Forward
0 new messages