Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: playframework/play1
...
head fork: fabiofalci/play
compare: lighthouse-1154-patch
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 15 additions and 0 deletions.
  1. +15 −0 modules/crud/app/controllers/CRUD.java
15 modules/crud/app/controllers/CRUD.java
View
@@ -4,6 +4,8 @@
import java.lang.reflect.*;
import java.lang.annotation.*;
+import org.apache.commons.lang.StringUtils;
+
import play.*;
import play.data.binding.*;
import play.mvc.*;
@@ -243,9 +245,22 @@ public static ObjectType get(Class<? extends Controller> controllerClass) {
try {
return (Class<? extends Model>) Play.classloader.loadClass(name);
} catch (ClassNotFoundException e) {
+ if (hasSubPackages(controllerClass)) {
+ name = controllerClass.getName().replace("$", "");
+ name = "models." + name.substring(name.indexOf(".") + 1, name.length() - 1);
+
+ try {
+ return (Class<? extends Model>) Play.classloader.loadClass(name);
+ } catch (ClassNotFoundException e1) {
+ }
+ }
return null;
}
}
+
+ public static boolean hasSubPackages(Class clazz) {
+ return StringUtils.countMatches(clazz.getName(), ".") > 1;
+ }
public Object getListAction() {
return Router.reverse(controllerClass.getName().replace("$", "") + ".list");

No commit comments for this range

Something went wrong with that request. Please try again.