final StackTraceElement[] stes = new Throwable().getStackTrace();
// let's iterate back in the stacktrace to find the recent action calls.
for (StackTraceElement st : stes) {
String controller = st.getClassName();
String action = st.getMethodName();
ApplicationClass conAppClass = Play.classes.getApplicationClass(controller);
if (conAppClass != null) {
Class controllerClass = conAppClass.javaClass;
if (JapidController.class.isAssignableFrom(controllerClass)) {
Method actionMethod = /* Java. */findActionMethod(action, controllerClass);
if (actionMethod != null) {
String expr = controller + "." + action;
// content negotiation
String format = Request.current().format;
if ("html".equals(format)) {
return expr;
} else {
String expr_format = expr + "_" + format;
if (expr_format.startsWith("controllers.")) {
expr_format = "japidviews" + expr_format.substring(expr_format.indexOf('.'));
}
ApplicationClass appClass = Play.classes.getApplicationClass(expr_format);
if (appClass != null)
return expr_format;
else {
// fallback
return expr;