Closed gbersac closed 10 years ago
I found out how to do it.
The key is to not follow the documentation and do not add the following line to application.conf :
application.global=play.utils.crud.GlobalCRUDSettings
Instead you should add/uncomment the following line (I am not sure this is a must do) :
application.global=Global
The you create the Global class in the playAppRoot/app/Global.java. This class extends the play.utils.crud.GlobalCRUDSettings class. Example :
import play.Logger;
import play.Application;
import play.utils.crud.*;
import models.User;
import java.util.List;
import play.libs.Yaml;
import com.avaje.ebean.Ebean;
public class Global extends GlobalCRUDSettings
{
@Override
public void onStart(Application app) {
super.onStart(app);
if (app.isDev()
&& app.configuration().getBoolean("insertTestData", false)
&& User.find.findIds().isEmpty()) {
Logger.debug("Load data");
Ebean.save((List) Yaml.load("test-data.yml"));
}
}
}
Hi Guillaume,
can you please update the documentation with your findings?
Ok, I'll do it.
Cordialement,Guillaume Bersac2bis avenue Guillemin92600 Asnière sur seine06.65.30.89.43
Date: Wed, 13 Aug 2014 06:58:48 -0700 From: notifications@github.com To: play2-crud@noreply.github.com CC: bersac_1@hotmail.fr Subject: Re: [play2-crud] GlobalCRUDSettings onStart is not working (#41)
Hi Guillaume,
can you please update the documentation with your findings?
— Reply to this email directly or view it on GitHub.
Hi,
I had a GlobalSettings class which worked fine when I began my project. I then moved to play2-crud and it is not working anymore.
My Global class is in the app/ folder. My code :
When I relaunch the application, type the command run and refresh my page, the log comment is not appearing. If I test it in the sample crud activator application, the same problem. Why ?