Package org.rendersnake.internal

Examples of org.rendersnake.internal.ContextMap


       
        html.render(SourceLink.example("LoginForm"));
    }

    private void renderErrorsOn(HtmlCanvas html) throws IOException {
        ContextMap session = html.getSession();
        if (session == null)
            return;
        Object usernameMsg = session.getObject(ERROR_LOGIN_USERNAME);
        Object passwordMsg = session.getObject(ERROR_LOGIN_PASSWORD);
        if (usernameMsg == null && passwordMsg == null)
            return;
        html
            .div(class_("errors"))
                .write((String)usernameMsg)
View Full Code Here


        this.renderStatisticsOn(html);
    }

    public void renderFormOn(HtmlCanvas html) throws IOException {// @formatter:off
        // either is empty, showing java or showing html
        ContextMap session = RequestUtils.getSession(html);
        String tidy = session.getString("tidy");
        String checked = "on".equals(tidy) ? "checked" : null;
        String java = session.getString("java");       
        String xhtml = session.getString("html");
        boolean hasJava = !StringUtils.isEmpty(java);
        boolean hasHtml = !StringUtils.isEmpty(xhtml);
        if (!hasJava && !hasHtml) {
            hasHtml = true;
            xhtml = "<table id=\"sample\" class=\"title\">\n" +
View Full Code Here

        html.render(new SiteLayoutWrapper(new TranslatorForm()));
    }

    public void post(HtmlCanvas html, HandlerResult result) throws IOException {
       
        ContextMap session = RequestUtils.getSession(html);
        boolean useTidy = "on".equals(RequestUtils.getParameter(html,"tidy"));
        String handle = RequestUtils.getParameter(html,"handle");
        if ("translate".equals(handle)) {
            ByteArrayInputStream input = new ByteArrayInputStream(RequestUtils.getParameter(html,"html").getBytes());
            HtmlToRenderSnakeTranslator translator = new HtmlToRenderSnakeTranslator();
            try {
                translator.translate(input,useTidy);
            } catch (Exception ex) {
                translator.errorMessage = ex.getMessage();
            }
            session.withString("java", translator.isSuccess() ? translator.toJavaSource() : translator.errorMessage);
            session.withString("html", RequestUtils.getParameter(html,"html"));
        }
        if ("back".equals(handle)) {
            session.withString("java", null);
        }
        if (useTidy) {
            session.withString("tidy", "on");
        } else {
            session.withString("tidy", null);
        }
        result.redirectTo("translator.html");
    }
View Full Code Here

        Integer integer = ctx.getInteger("size");
        System.out.println(integer);
    }
    public void testAccess(){
        ctx.withObject("map", new SimpleContextMap());
        ContextMap map = ctx.getContextMap("map");
        map.withString("s","s");
        // TODO cannot use cascading anymore, fix it
        map.withBoolean("b", true);
    }
View Full Code Here

    /**
     * @param html
     * @return aString | null which is the value of a parameter of the inbound Http request.
     */
    public static String getParameter(HtmlCanvas html, String key) {
        ContextMap map = getParameters(html);
        if (null == map) return null;
        return map.getString(key);
    }   
View Full Code Here

     * @param html
     * @param name
     * @return aString | null which is the value of a header of the inbound Http request.
     */
    public static String getHeaderValue(HtmlCanvas html, String name) {
        ContextMap map = html.getPageContext().getContextMap(PageContext.REQUEST_HEADERS);
        if (null == map) return null;
        return map.getString(name);
    }
View Full Code Here

TOP

Related Classes of org.rendersnake.internal.ContextMap

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.