Package com.astamuse.asta4d.render

Examples of com.astamuse.asta4d.render.Renderer


    private static final String JAVA_PACKAGE = "/com/astamuse/asta4d/sample";
    private static final String VM_ARG = "asta4d.sample.source_location";
    private static final String SHOW_MARK = "@ShowCode:";

    public Renderer showCode(HttpServletRequest request, String file, String startMark, String endMark, String title) {
        Renderer render = new GoThroughRenderer();
        ServletContext servletContext = request.getSession().getServletContext();
        String contents = readFileByLines(servletContext, file, SHOW_MARK + startMark, SHOW_MARK + endMark);
        render.add("div", makeShowHtml(file, title, contents));

        return render;
    }
View Full Code Here


public class ComplicatedSnippet {

    // @ShowCode:showRenderertypesStart
    public Renderer render() {
        // それ自体は何もしない Renderer です。
        Renderer render = new GoThroughRenderer();

        // 該当 Element の子要素全てを置換します。

        ChildReplacer replacer = new ChildReplacer(createElement());
        render.add("ul${symbol_pound}childreplacer", replacer);

        // 該当 Element を削除します。
        render.add("ul${symbol_pound}clearnode", new ClearNode());

        // レンダリング結果をデバッグ出力します。
        render.addDebugger("current element");

        return render;
    }
View Full Code Here

    // @ShowCode:showRenderertypesEnd

    // @ShowCode:showPassvariablesStart
    public Renderer outer() {
        // 文字列, 整数, Date型の値, List型の値を内部Snippetで使用するためにセットします。
        Renderer render = new GoThroughRenderer();
        render.add("div${symbol_pound}inner", "name", "baz");
        render.add("div${symbol_pound}inner", "age", "30");
        render.add("div${symbol_pound}inner", "currenttime", new Date());

        List<String> list = new ArrayList<>();
        list.add("This text is passed by outer snippet.(1)");
        list.add("This text is passed by outer snippet.(2)");
        list.add("This text is passed by outer snippet.(3)");
        render.add("div${symbol_pound}inner", "list", list);
        return render;
    }
View Full Code Here

        return render;
    }

    public Renderer inner(String name, int age, Date currenttime, List<String> list) {
        // 外部Snippetでセットされた値を変数から取得し、使用します。
        Renderer render = new GoThroughRenderer();
        render.add("p${symbol_pound}name span", name);
        render.add("p${symbol_pound}age span", age);
        render.add("p${symbol_pound}currenttime span", DateFormatUtils.format(currenttime, "yyyy/MM/dd HH:mm:ss"));
        render.add("ul${symbol_pound}list li", list);
        return render;
    }
View Full Code Here

    }

    // @ShowCode:showPassvariablesEnd
    // @ShowCode:showDynamicsnippetStart
    public Renderer createDynamicSnippet() {
        Renderer render = new GoThroughRenderer();
        Element snippet = new SnippetNode("SimpleSnippet");
        snippet.attr("name", "Dynamic Snippet");
        render.add("div${symbol_pound}snippet", snippet);
        Element embed = new EmbedNode("/templates/embed/embedded.html");
        render.add("div${symbol_pound}embed", embed);
        return render;
    }
View Full Code Here

    }

    // @ShowCode:showContextdataEnd
    // @ShowCode:showLocalizeStart
    public Renderer setWeatherreportParam() {
        Renderer render = new GoThroughRenderer();
        Locale locale = Context.getCurrentThreadContext().getCurrentLocale();
        if (locale.equals(Locale.JAPANESE) || locale.equals(Locale.JAPAN)) {
            render.add("afd|msg${symbol_pound}weatherreport1", "p0", "晴れ");
        } else {
            render.add("afd|msg${symbol_pound}weatherreport1", "p0", "sunny");
        }
        render.add("afd|msg${symbol_pound}weatherreport2", "p0", "cloudy");
        render.add("afd|msg${symbol_pound}weatherreport3", "p0", "rain");
        return render;
    }
View Full Code Here

        return Renderer.create("*", element);
    }

    // @ShowCode:showVariableinjectionEnd
    public Renderer setProfile() {
        Renderer render = new GoThroughRenderer();
        render.add("p${symbol_pound}name span", "asta4d");
        render.add("p${symbol_pound}age span", "20");
        return render;
    }
View Full Code Here

    }

    // @ShowCode:showSnippetEnd
    // @ShowCode:showVariableinjectionStart
    public Renderer setProfileByVariableInjection(String name, int age) {
        Renderer render = new GoThroughRenderer();
        render.add("p${symbol_pound}name span", name);
        render.add("p${symbol_pound}age span", age);
        return render;
    }
View Full Code Here

    }

    // @ShowCode:showVariableinjectionEnd
    // @ShowCode:showAttributevaluesStart
    public Renderer manipulateAttrValues() {
        Renderer render = new GoThroughRenderer();
        render.add("input${symbol_pound}yes", "checked", "checked");
        render.add("button${symbol_pound}delete", "disabled", null);
        render.add("li${symbol_pound}plus", "+class", "red");
        render.add("li${symbol_pound}minus", "-class", "bold");
        return render;
    }
View Full Code Here

                 * Commonly, it is not a problem, but it is difficult to debug since the original exception had been
                 * ignored and there is no any information about it at anywhere. So at least, we output the exception
                 * in log to help debug.
                 */
                try {
                    Renderer renderer = Context.with(context, caller);
                    return new FutureRendererHolder(snippetRef, renderer);
                } catch (Exception ex) {
                    logger.error("", ex);
                    throw ex;
                }
View Full Code Here

TOP

Related Classes of com.astamuse.asta4d.render.Renderer

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.