Package play.mvc.Router

Examples of play.mvc.Router.ActionDefinition


   * @param name
   * @param args
   * @return
   */
  public static String jsRoute(String name, String... args) {
        final ActionDefinition action = urlMapper.lookupActionDefinition(name, args);
        StringBuffer sb = new StringBuffer();
        sb.append("{");
        if (action.args.isEmpty()) {
          sb.append("url: function() { return '" + action.url.replace("&", "&") + "'; },");
        } else {
View Full Code Here


   *            the runtime value of the parameters used to call the action,
   *            e.g. 123 from evaluating "post.previous().id"
   */
  @Override
  public String lookup(String actionString, Object[] params) {
    ActionDefinition ad = lookupActionDefinition(actionString, params);
    return ad.toString();
  }
View Full Code Here

    return ad.toString();
  }

  public ActionDefinition lookupActionDefinition(String actionString,
      Object[] params) {
    ActionDefinition ad = new ActionBridge(false).invokeMethod(actionString, params);
    return ad;
  }
View Full Code Here

   */
  @Override
  public String lookup(String actionString, Object[] params) {
    ActionBridge ab = new ActionBridge(false);

    ActionDefinition ad = ab.invokeMethod(actionString, params);
    return ad.toString();
  }
View Full Code Here

           * sub.setVariablePrefix("{"); sub.setVariableSuffix("}");
           * String url = sub.replace(urlPattern); return url; }
           */
          return null;
        } else {
          ActionDefinition actionDef = Router.reverse(action, paramMap);
          // was doing some hacking for caching. don't do it now for
          // Compatibility with remote
          // Route route = actionDef.route;
          // // find is the route is cacheable. it's hard to cache
          // path
          // // with constrained parameter
          // //
          // String path = route.path;
          // if (!path.contains("<")) {
          // // cacheable
          // if (path.endsWith("?"))
          // path = path.substring(0, path.length() - 1);
          // getActionCache().put(k, path);
          // }
          return actionDef.toString();
        }
      } catch (ActionNotFoundException e) {
        throw new RuntimeException(e + ". No matching route in reverse lookup: " + actionString);
//        throw new NoRouteFoundException(action, null);
      }
View Full Code Here

                }

            }
            try {

                ActionDefinition actionDefinition = Router.reverse(action, newArgs);

                if (_currentReverse.get() != null) {
                    ActionDefinition currentActionDefinition = _currentReverse.get();
                    currentActionDefinition.action = actionDefinition.action;
                    currentActionDefinition.url = actionDefinition.url;
                    currentActionDefinition.method = actionDefinition.method;
                    currentActionDefinition.star = actionDefinition.star;
                    currentActionDefinition.args = actionDefinition.args;
View Full Code Here

     * }
     * String url = action.url;
     * </code>
     */
    protected static ActionDefinition reverse() {
        ActionDefinition actionDefinition = new ActionDefinition();
        _currentReverse.set(actionDefinition);
        return actionDefinition;
    }
View Full Code Here

                }

            }
            try {

                ActionDefinition actionDefinition = Router.reverse(action, newArgs);

                if (_currentReverse.get() != null) {
                    ActionDefinition currentActionDefinition = _currentReverse.get();
                    currentActionDefinition.action = actionDefinition.action;
                    currentActionDefinition.url = actionDefinition.url;
                    currentActionDefinition.method = actionDefinition.method;
                    currentActionDefinition.star = actionDefinition.star;
                    currentActionDefinition.args = actionDefinition.args;
View Full Code Here

     * }
     * String url = action.url;
     * </code>
     */
    protected static ActionDefinition reverse() {
        ActionDefinition actionDefinition = new ActionDefinition();
        _currentReverse.set(actionDefinition);
        return actionDefinition;
    }
View Full Code Here

    public static void _jsRoute(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        final Object arg = args.get("arg");
        if (!(arg instanceof ActionDefinition)) {
            throw new TemplateExecutionException(template.template, fromLine, "Wrong parameter type, try #{jsRoute @Application.index() /}", new TagInternalException("Wrong parameter type"));
        }
        final ActionDefinition action = (ActionDefinition)arg;
        out.print("{");
        if (action.args.isEmpty()) {
            out.print("url: function() { return '" + action.url.replace("&amp;", "&") + "'; },");
        } else {
            out.print("url: function(args) { var pattern = '" + action.url.replace("&amp;", "&") + "'; for (var key in args) { pattern = pattern.replace(':'+key, args[key]); } return pattern; },");
View Full Code Here

TOP

Related Classes of play.mvc.Router.ActionDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.