For example:
Category extends Controller{
static void categoryList(){
//do logic to build category list
render(categories);
}
}
views/Category categoryList.html:
<ul>
#{list items:categories, as:category}
...
#{/list}
</ul>
In my main template, I've tried the following combinations:
#{include @{Category.categoryList} /}
#{include "/category/categoryList" /}
The 1st has an error "include tag not terminated" and the second says
"template not found". Is there some other way of doing this that I'm
missing?
Thanks
You should extract your code in the model part. The controller part
must be a thin wrapper around your application functionalities.
> --
> 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.
>
>
I could do it via AJAX, but that seems like a messy work-around.
#{list items:models.Category.all(), ...
Or are you saying I should put the code to replicate the work of the
controller in my tag? Or create a helper class to do the work (which
would need access to User,Session,JPA,etc) then use that inside the
tag? It would seem easier to just be able to use the existing
framework and allow #{include to include the generated output of a
controller/action like <jsp:include> does.
Well the model layer should contains all this business logic,
especially the non-trivial one. The controllers should not implement
any business logic directly, especially if this logic need to be
reused in several part of the application.
Again the idea is to keep the controller and view parts as light as possible.
> It would seem easier to just be able to use the existing
> framework and allow #{include to include the generated output of a
> controller/action like <jsp:include> does.
Not really because the framework is designed to work with the HTTP
request concept. Allowing to include an HTTP request into another one
will complexify a lot the framework design.
--------------------------------------------------
From: "John Pletka" <jpl...@abraxis.com>
Sent: Friday, March 26, 2010 10:09 PM