Package ninja

Examples of ninja.Result


    }

    @Timed   
    public Result flashError(Context context, FlashScope flashScope) {
        Result result = Results.html();
        // sets a 18n flash message and adds a timestamp to make sure formatting works
        Optional<String> flashMessage = messages.get("flashError", context, Optional.of(result), "PLACEHOLDER");
        if (flashMessage.isPresent()) {
            flashScope.error(flashMessage.get());
        }
View Full Code Here


    }

    @Timed   
    public Result flashAny(Context context, FlashScope flashScope) {
        Result result = Results.html();
        // sets a 18n flash message and adds a timestamp to make sure formatting works
        Optional<String> flashMessage = messages.get("flashAny", context, Optional.of(result), "PLACEHOLDER");
        if (flashMessage.isPresent()) {
            flashScope.put("any", flashMessage.get());
        }
View Full Code Here

    public Result index(Context context) {
        // Only render the page. It contains some language specific strings.
        // It will use the requested language (or a fallback language)
        // from Accept-Language header
        Result result = Results.html();
        // just in case we set the language => we remove it...
        lang.clearLanguage(result);
       
        return result;
    }
View Full Code Here

    }
   
   
    public Result indexWithLanguage(@PathParam("language") String language) {
       
        Result result = Results.ok().html().template("/views/I18nController/index.ftl.html");
        // This gets an url like /i18n/en
        // language is then the "en" part of the url.
       
        // We take that part and set that language as the default language
        // of the framework for this user.
View Full Code Here

    public Result index(Context context) {
        // Only render the page. It contains some language specific strings.
        // It will use the requested language (or a fallback language)
        // from Accept-Language header
        Result result = Results.html();
        // just in case we set the language => we remove it...
        lang.clearLanguage(result);

        Calendar c = Calendar.getInstance();
        c.add(Calendar.DATE, -1);
        Date date = c.getTime();
        result.render("date", date);

        return result;
    }
View Full Code Here

    }


    public Result indexWithLanguage(@PathParam("language") String language) {

        Result result = Results.ok().html().template("/views/PrettyTimeController/index.ftl.html");
        // This gets an url like /prettyTime/en
        // language is then the "en" part of the url.

        // We take that part and set that language as the default language
        // of the framework for this user.
        lang.setLanguage(language, result);

        Calendar c = Calendar.getInstance();
        c.add(Calendar.DATE, -1);
        Date date = c.getTime();
        result.render("date", date);

        return result;

    }
View Full Code Here

                }

            }
        };

        return new Result(200).render(renderable);

    }
View Full Code Here

        Lang lang = new LangImpl(ninjaProperties);
      
       
        // 1) with context and result => but result does not have a default lang
        Result result = Results.ok();
        Optional<String> language = lang.getLanguage(context, Optional.of(result));
        assertEquals("de", language.get());
       
       
        // 2) with context and result => result has already new lang set...
        result = Results.ok();
        cookie = Cookie.builder("NINJA_TEST" + NinjaConstant.LANG_COOKIE_SUFFIX, "en").build();
        result.addCookie(cookie);
       
        language = lang.getLanguage(context, Optional.of(result));
        assertEquals("en", language.get());
       
       
View Full Code Here

        when(ninjaProperties.getOrDie(NinjaConstant.applicationCookiePrefix)).thenReturn("NINJA_TEST");
      
        Lang lang = new LangImpl(ninjaProperties);
       
        // test with result
        Result result = Results.noContent();
       
        result = lang.setLanguage("to", result);
        assertEquals("to", result.getCookie(cookie.getName()).getValue());
        assertEquals(Result.SC_204_NO_CONTENT, result.getStatusCode());


    }
View Full Code Here

        when(ninjaProperties.getOrDie(NinjaConstant.applicationCookiePrefix)).thenReturn("NINJA_TEST");

        Lang lang = new LangImpl(ninjaProperties);
       
        Result result = Results.ok();
       
        lang.clearLanguage(result);
       
        Cookie returnCookie = result.getCookie(cookie.getName());
        assertEquals("", returnCookie.getValue());
        assertEquals(0, returnCookie.getMaxAge());
       
    }
View Full Code Here

TOP

Related Classes of ninja.Result

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.