play.mvc.Controller Java Examples
The following examples show how to use
play.mvc.Controller.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CRUD.java From restcommander with Apache License 2.0 | 6 votes |
public static ObjectType get(Class<? extends Controller> controllerClass) { Class<? extends Model> entityClass = getEntityClassForController(controllerClass); if (entityClass == null || !Model.class.isAssignableFrom(entityClass)) { return null; } ObjectType type; try { type = (ObjectType) Java.invokeStaticOrParent(controllerClass, "createObjectType", entityClass); } catch (Exception e) { Logger.error(e, "Couldn't create an ObjectType. Use default one."); type = new ObjectType(entityClass); } type.name = controllerClass.getSimpleName().replace("$", ""); type.controllerName = controllerClass.getSimpleName().toLowerCase().replace("$", ""); type.controllerClass = controllerClass; return type; }
Example #2
Source File: CRUD.java From restcommander with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public static Class<? extends Model> getEntityClassForController(Class<? extends Controller> controllerClass) { if (controllerClass.isAnnotationPresent(For.class)) { return controllerClass.getAnnotation(For.class).value(); } for(Type it : controllerClass.getGenericInterfaces()) { if(it instanceof ParameterizedType) { ParameterizedType type = (ParameterizedType)it; if (((Class<?>)type.getRawType()).getSimpleName().equals("CRUDWrapper")) { return (Class<? extends Model>)type.getActualTypeArguments()[0]; } } } String name = controllerClass.getSimpleName().replace("$", ""); name = "models." + name.substring(0, name.length() - 1); try { return (Class<? extends Model>) Play.classloader.loadClass(name); } catch (ClassNotFoundException e) { return null; } }
Example #3
Source File: LessonControllerUtils.java From judgels with GNU General Public License v2.0 | 5 votes |
public static Result downloadFile(File file) { if (!file.exists()) { return Results.notFound(); } Controller.response().setContentType("application/x-download"); Controller.response().setHeader("Content-disposition", "attachment; filename=" + file.getName()); return Results.ok(file); }
Example #4
Source File: LessonControllerUtils.java From judgels with GNU General Public License v2.0 | 4 votes |
public static void setCurrentStatementLanguage(String languageCode) { Controller.session("currentStatementLanguage", languageCode); }
Example #5
Source File: LessonControllerUtils.java From judgels with GNU General Public License v2.0 | 4 votes |
public static String getCurrentStatementLanguage() { return Controller.session("currentStatementLanguage"); }
Example #6
Source File: LessonStatementController.java From judgels with GNU General Public License v2.0 | 4 votes |
private void appendStatementLanguageSelection(HtmlTemplate template, String currentLanguage, Set<String> allowedLanguages, Call target) { template.transformContent(c -> statementLanguageSelectionLayout.render(target.absoluteURL(Controller.request(), Controller.request().secure()), allowedLanguages, currentLanguage, c)); }
Example #7
Source File: ProblemControllerUtils.java From judgels with GNU General Public License v2.0 | 4 votes |
public static void setCurrentStatementLanguage(String languageCode) { Controller.session("currentStatementLanguage", languageCode); }
Example #8
Source File: ProblemControllerUtils.java From judgels with GNU General Public License v2.0 | 4 votes |
public static String getCurrentStatementLanguage() { return Controller.session("currentStatementLanguage"); }
Example #9
Source File: ProblemControllerUtils.java From judgels with GNU General Public License v2.0 | 4 votes |
public static void setJustCreatedProblem(String slug, String additionalNote, String initLanguageCode) { Controller.session("problemSlug", slug); Controller.session("problemAdditionalNote", additionalNote); Controller.session("initLanguageCode", initLanguageCode); }
Example #10
Source File: ProblemControllerUtils.java From judgels with GNU General Public License v2.0 | 4 votes |
public static void removeJustCreatedProblem() { Controller.session().remove("problemSlug"); Controller.session().remove("problemAdditionalNote"); Controller.session().remove("initLanguageCode"); }
Example #11
Source File: ProblemControllerUtils.java From judgels with GNU General Public License v2.0 | 4 votes |
public static String getJustCreatedProblemSlug() { return Controller.session("problemSlug"); }
Example #12
Source File: ProblemControllerUtils.java From judgels with GNU General Public License v2.0 | 4 votes |
public static String getJustCreatedProblemAdditionalNote() { return Controller.session("problemAdditionalNote"); }
Example #13
Source File: ProblemControllerUtils.java From judgels with GNU General Public License v2.0 | 4 votes |
public static String getJustCreatedProblemInitLanguageCode() { return Controller.session("initLanguageCode"); }
Example #14
Source File: AbstractProblemController.java From judgels with GNU General Public License v2.0 | 4 votes |
protected void appendStatementLanguageSelection(HtmlTemplate template, String currentLanguage, Set<String> allowedLanguages, Call target) { template.transformContent(c -> statementLanguageSelectionLayout.render(target.absoluteURL(Controller.request(), Controller.request().secure()), allowedLanguages, currentLanguage, c)); }
Example #15
Source File: FunctionalTest.java From restcommander with Apache License 2.0 | 4 votes |
protected static URL reverse() { ControllerInstrumentation.stopActionCall(); ActionDefinition actionDefinition = new ActionDefinition(); Controller._currentReverse.set(actionDefinition); return new URL(actionDefinition); }