Two things are going wrong here, which might be two problems or might have the same root: they both feel like a config error somewhere, hence putting them together. Apologies is advance if this is confusing the issue...
I'm using Ninja Framework, still learning my way around starting from the Hello World example. I can serve pages with GET and POST using Routes, a Controller and html OK.
In case it is relevant, I'm running on a fresh CentOS VM, using NetBeans to write, Firefox to test. I have restarted Ninja (many times).
Problem 1: NinjaProperties isn't visible in code. I had understood that I can put, for example
import com.google.inject.Inject;
public abstract class PersistDB {
@Inject
NinjaProperties ninjaProperties;
...
protected void loadProps() {
dbReadServer = ninjaProperties.getWithDefault(DB_READ_SERVER_PROP, DBSERVER_DEFAULT);
...
}
}
public class UsersDB {
public UsersDB() {
loadProps();
}
}
and have my model code access the application.conf file to extract properties. However ninjaProperties is coming back null.
Problem 2: The JSON parsing described at Ninja docs where adding a simple class with the right field names to the controller signature caused JSON to be translated behind the scenes isn't working. I can add the class, with the right fields, to the Controller method signature but it is always null. Using GSON I can extract the object for myself so I have a work-around but that also confirms that it is something in Ninja that isn't working.
The code follows the example pretty closely:
package controllers;
public class UserRegisterReq {
String email;
String identName;
String password;
}
and
package controllers;
import com.google.inject.Singleton;
import models.user.User;
import models.user.UserResult;
import ninja.Context;
import ninja.Result;
import ninja.Results;
import ninja.session.Session;
@Singleton
public class UserController {
...
public Result doRegisterPost(UserRegisterReq req, Context context) {
Session session = context.getSession();
UserResult ur;
ur = User.registerUser(req.email, req.password, req.identName);
...
}
Any ideas? Thanks in advance...