/** * Get the URL by the controllers package, class, method and parameters. It * use reflection for get the reverse route. * * @param controllerPackage * The name of the package of the controller * @param controllerClass * The name of the controller class * @param methodName * The method name in the controller, i.e. action * @param methodArguments * The arguments of the method * @return * Reversed URL * @throws Exception * Any exception in the case of reversion */ private static String reverseUrl( final ClassLoader classLoader, final String controllerPackage, final String controllerClass, final String methodName, final RouteMethodArguments methodArguments) throws Exception { // Load the auto generated class "routes". final Class<?> routerClass = classLoader.loadClass(controllerPackage + ".routes"); // Get the reverse router object of the controller. final Field declaredField = routerClass.getDeclaredField(controllerClass); // It's static field. final Object object = declaredField.get(null); final Class<?> type = declaredField.getType(); // Get the action of the reverse controller. final Method routerMethod = type.getMethod(methodName, methodArguments.types); final Call invoke = (Call) routerMethod.invoke(object, methodArguments.values); // Get the URL of the action. return invoke.url(); }
@Override public Call auth(final String provider) { // You can provide your own authentication implementation, // however the default should be sufficient for most cases return com.feth.play.module.pa.controllers.routes.Authenticate .authenticate(provider); }
@Override public Call onException(final AuthException e) { if (e instanceof AccessDeniedException) { return routes.Signup .oAuthDenied(((AccessDeniedException) e) .getProviderKey()); } // more custom problem handling here... return super.onException(e); }
@Test public void testPager() { start(); Pager pager = new Pager(); pager.index = 10; pager.size = 20; // Test that the pager is bound/unbound correctly Call call = routes.Application.paged(pager); assertEquals("/paged?p.index=10&p.size=20", call.url()); Result result = route(fakeRequest(call.method(), call.url())); assertEquals("Pager{index=10, size=20}", contentAsString(result)); }
@Override public Call onException(final AuthException e) { if (e instanceof AccessDeniedException) { return routes.Public .oAuthDenied(((AccessDeniedException) e) .getProviderKey()); } // more custom problem handling here... return super.onException(e); }
private BreadcrumbLinkViewModel createProductLink(final ProductWithVariant productWithVariant) { final BreadcrumbLinkViewModel linkViewModel = new BreadcrumbLinkViewModel(); linkViewModel.setText(productWithVariant.getProduct().getName()); final String productUrl = getProductReverseRouter() .productDetailPageCall(productWithVariant.getProduct(), productWithVariant.getVariant()) .map(Call::url) .orElse(""); linkViewModel.setUrl(productUrl); return linkViewModel; }
protected void fillProductSlug(final WishlistItemViewModel viewModel, final LineItem lineItem) { if (lineItem != null) { final String productSlug = productReverseRouter .productDetailPageCall(lineItem) .map(Call::url) .orElse(""); viewModel.setUrl(productSlug); } }
/**** PRIVATE OPERATIONS ****/ private static Result showPairs() { String pageTitle = "Debug"; Html topBar = debug_topbar.render(project.getName()); Html topNav = common_topnav.render(project); Html content = facets_layout.render(); List<Call> dynamicJs = new ArrayList<Call>(); dynamicJs.add(controllers.project.routes.ProjectController.javascriptRoutes()); dynamicJs.add(controllers.routes.Assets.at("javascripts/project/project.js")); dynamicJs.add(controllers.debug.routes.DebugController.javascriptRoutes()); dynamicJs.add(controllers.routes.Assets.at("javascripts/bootstrap/bootstrap-tree.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/facets_layout/facets_layout.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/debug/debug_error_filter.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/debug/debug_facets_layout.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/debug/debug_match_status_filter.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/debug/debug_matching_summary.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/debug/debug_rule_filter.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/debug/debug_feature_thresh_filter.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/debug/debug_skyline_filter.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/debug/debug_table.js")); dynamicJs.add(controllers.routes.Assets.at("javascripts/debug/debug.js")); List<Call> dynamicCss = new ArrayList<Call>(); dynamicCss.add(controllers.routes.Assets.at("stylesheets/bootstrap/bootstrap-tree.min.css")); dynamicCss.add(controllers.routes.Assets.at("stylesheets/facets_layout/facets_layout.css")); dynamicCss.add(controllers.routes.Assets.at("stylesheets/debug/debug.css")); Html page = common_main.render(pageTitle, topBar, topNav, content, dynamicCss, dynamicJs); return ok(page); }
public String authorizeUrl(Call returnTo) { return URL.build(configuration.authorizationEndpoint, Scala.varargs( param("response_type", "code"), param("client_id", configuration.clientId), param("redirect_uri", routes.OAuth.callback().absoluteURL(request())), param("scope", configuration.scope), param("state", returnTo.url()) )); }
@Override protected Call userExists(final UsernamePasswordAuthUser authUser) { return routes.Signup.exists(); }
@Override protected Call userUnverified(final UsernamePasswordAuthUser authUser) { return routes.Signup.unverified(); }
@Override public Call login() { // Your login page return routes.Application.login(); }
@Override public Call afterAuth() { // The user will be redirected to this page after authentication // if no original URL was saved return routes.Application.index(); }
@Override public Call afterLogout() { return routes.Application.index(); }
@Override public Call askMerge() { return routes.Account.askMerge(); }
@Override public Call askLink() { return routes.Account.askLink(); }
@Override public Call getRouteForAjaxWaitImage() { return controllers.routes.Assets.versioned(new Asset("images/ajax-loader.gif")); }
@Override public Call getRouteForDynamicSingleCustomAttributeApi() { return controllers.routes.Application.dynamicSingleCustomAttributeApi(); }
@Override public Call getRouteForDownloadAttachedFile(Long attachmentId) { return controllers.routes.Application.downloadFileAttachment(attachmentId); }
@Override public Call getRouteForDeleteAttachedFile(Long attachmentId) { return controllers.routes.Application.deleteFileAttachment(attachmentId); }
@Override public Call getRouteForFilterConfigurationCreate() { return framework.utils.routes.FilterConfigController.filterConfigurationCreate(); }
@Override public Call getRouteForFilterConfigurationSave() { return framework.utils.routes.FilterConfigController.filterConfigurationSave(); }
@Override public Call getRouteForFilterConfigurationChange() { return framework.utils.routes.FilterConfigController.filterConfigurationChange(); }
@Override public Call getRouteForFilterConfigurationEdit() { return framework.utils.routes.FilterConfigController.filterConfigurationEdit(); }
@Override public Call getRouteForFilterConfigurationDelete() { return framework.utils.routes.FilterConfigController.filterConfigurationDelete(); }
@Override public Call getRouteForFilterConfigurationShare() { return framework.utils.routes.FilterConfigController.filterConfigurationShare(); }
@Override public Call getRouteForFilterConfigurationSearchPrincipal() { return framework.utils.routes.FilterConfigController.filterConfigurationSearchPrincipal(); }
@Override public Call getRouteForFilterConfigurationClear() { return routes.FilterConfigController.filterConfigurationClear(); }
@Override protected Call list(QuestionsFilter questionsFilter, Sorter s, Pager p) { return routes.ListQuestions.list(f,s,p); }
@Override public Call resize() { return routes.ListQuestions.resize(f,s, p.offset()); }
@Override public Call action() { return routes.ListQuestions.filter(s,p); }
@Override public Call previous() { return list(f,s,p.previous()); }
@Override public Call next() { return list(f,s,p.next()); }
@Override public Call sort(String field) { return list(f,s.forColumn(field),p); }
@Override protected Call list(SchoolsFilter schoolsFilter, Sorter s, Pager p) { return routes.Schools.list(f,s,p); }
@Override public Call resize() { return routes.Schools.resize(f,s, p.offset()); }
@Override public Call action() { return routes.Schools.filter(s,p); }
@Override protected Call list(SchoolsFilter schoolsFilter, Sorter s, Pager p) { return routes.TeacherSchools.show(f,s,p); }
@Override public Call resize() { return routes.TeacherSchools.resize(f,s, p.offset()); }