Package play.exceptions

Examples of play.exceptions.TemplateExecutionException


    }

    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;", "&") + "'; },");
View Full Code Here


        }
    }

    public static void _ifError(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        if (args.get("arg") == null) {
            throw new TemplateExecutionException(template.template, fromLine, "Please specify the error key", new TagInternalException("Please specify the error key"));
        }
        if (Validation.hasError(args.get("arg").toString())) {
            body.call();
            TagContext.parent().data.put("_executeNextElse", false);
        } else {
View Full Code Here

        }
    }

    public static void _errorClass(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        if (args.get("arg") == null) {
            throw new TemplateExecutionException(template.template, fromLine, "Please specify the error key", new TagInternalException("Please specify the error key"));
        }
        if (Validation.hasError(args.get("arg").toString())) {
            out.print("hasError");
        }
    }
View Full Code Here

        }
    }

    public static void _error(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        if (args.get("arg") == null && args.get("key") == null) {
            throw new TemplateExecutionException(template.template, fromLine, "Please specify the error key", new TagInternalException("Please specify the error key"));
        }
        String key = args.get("arg") == null ? args.get("key") + "" : args.get("arg") + "";
        Error error = Validation.error(key);
        if (error != null) {
            if (args.get("field") == null) {
View Full Code Here

    }

    public static void _get(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        Object name = args.get("arg");
        if (name == null) {
            throw new TemplateExecutionException(template.template, fromLine, "Specify a variable name", new TagInternalException("Specify a variable name"));
        }
        Object value = BaseTemplate.layoutData.get().get(name);
        if (value != null) {
            out.print(value);
        } else {
View Full Code Here

    }

    public static void _extends(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        try {
            if (!args.containsKey("arg") || args.get("arg") == null) {
                throw new TemplateExecutionException(template.template, fromLine, "Specify a template name", new TagInternalException("Specify a template name"));
            }
            String name = args.get("arg").toString();
            if (name.startsWith("./")) {
                String ct = BaseTemplate.currentTemplate.get().name;
                if (ct.matches("^/lib/[^/]+/app/views/.*")) {
View Full Code Here

    @SuppressWarnings("unchecked")
    public static void _include(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        try {
            if (!args.containsKey("arg") || args.get("arg") == null) {
                throw new TemplateExecutionException(template.template, fromLine, "Specify a template name", new TagInternalException("Specify a template name"));
            }
            String name = args.get("arg").toString();
            if (name.startsWith("./")) {
                String ct = BaseTemplate.currentTemplate.get().name;
                if (ct.matches("^/lib/[^/]+/app/views/.*")) {
View Full Code Here

    @SuppressWarnings("unchecked")
    public static void _render(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        try {
            if (!args.containsKey("arg") || args.get("arg") == null) {
                throw new TemplateExecutionException(template.template, fromLine, "Specify a template name", new TagInternalException("Specify a template name"));
            }
            String name = args.get("arg").toString();
            if (name.startsWith("./")) {
                String ct = BaseTemplate.currentTemplate.get().name;
                if (ct.matches("^/lib/[^/]+/app/views/.*")) {
View Full Code Here

    public static void _table(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {

        // Retrieve the data
        final Iterable<?> data = (Iterable<?>) args.remove("arg");
        if (data == null) {
            throw new TemplateExecutionException(template.template,
                                                 fromLine,
                                                 "Please specify the data to display",
                                                 new TagInternalException("Please specifiy the data to display"));
        }

        // Ensure data are not empty
        if (!data.iterator().hasNext()) {
            out.println(Messages.get("table.nodata"));
            return;
        }

        TableContentPrinter contentPrinter;

        if (body == null) {
            // Automatically fill the table content with the models properties
            final Iterable<? extends Model> modelData = (Iterable<? extends Model>)data;
            final Class<? extends Model> clazz = modelData.iterator().next().getClass();
            if (Model.class.isAssignableFrom(clazz)) {
                Map<String, String> properties;
                if (args.containsKey("columns")) {
                    properties = (Map<String, String>)args.remove("columns");
                } else {
                    // Display all properties
                    properties = new LinkedHashMap<String, String>();
                    for(Model.Property property : Model.Manager.factoryFor(clazz).listProperties()) {
                        properties.put(property.name, Messages.get(property.name));
                    }
                }
                contentPrinter = new ModelPrinter(properties);
            } else {
                throw new TemplateExecutionException(template.template,
                                                     fromLine,
                                                     "Please use Play! models in the 'table' tag",
                                                     new TagInternalException("Please use Play! models in the 'table' tag"));
            }
        } else {
            // Fill the table content with the execution of its body
            final String it = (String) args.remove("as");
            if (it == null) {
                throw new TemplateExecutionException(template.template,
                                                     fromLine,
                                                     "Missing parameter 'as'",
                                                     new TagInternalException("Missing parameter 'as'"));
            }
            contentPrinter = new TagPrinter(body, it);
View Full Code Here

    public static void _column(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        // Retrieve the table state (“head” or “content”)
        final String state = (String) TagContext.parent("table").data.get("dataview.state");
        if (state == null) {
            throw new TemplateExecutionException(template.template,
                                                 fromLine,
                                                 "The 'column' tag should be used inside a 'table' tag",
                                                 new TagInternalException("The 'column' tag should be used inside a 'table' tag"));
        }
        if (state.equals("head")) {
View Full Code Here

TOP

Related Classes of play.exceptions.TemplateExecutionException

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.