use of ninja.Result in project ninja by ninjaframework.
the class AbstractContextTest method finalizeInAbstractContextSavesFlashSessionCookies.
@Test
public void finalizeInAbstractContextSavesFlashSessionCookies() {
AbstractContextImpl context = spy(abstractContext);
Result result = Results.json();
Cookie cookie = Cookie.builder("TEST", "value").build();
result.addCookie(cookie);
doNothing().when(context).addCookie(cookie);
ResponseStreams streams = context.finalizeHeaders(result);
// abstract finalizeHeaders does not return anything
assertThat(streams, is(nullValue()));
verify(flashCookie, times(1)).save(context);
verify(sessionCookie, times(1)).save(context);
verify(context, times(1)).addCookie(cookie);
}
use of ninja.Result in project ninja by ninjaframework.
the class PrettyTimeController method indexWithLanguage.
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;
}
use of ninja.Result in project ninja by ninjaframework.
the class ApplicationController method flashSuccess.
@Timed
public Result flashSuccess(FlashScope flashScope, Context context) {
Result result = Results.html();
// sets a 18n flash message and adds a timestamp to make sure formatting works
Optional<String> flashMessage = messages.get("flashSuccess", context, Optional.of(result), "PLACEHOLDER");
if (flashMessage.isPresent()) {
flashScope.success(flashMessage.get());
}
return result;
}
use of ninja.Result in project ninja by ninjaframework.
the class I18nController method indexWithLanguage.
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.
lang.setLanguage(language, result);
return result;
}
use of ninja.Result in project ninja by ninjaframework.
the class I18nController method index.
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;
}
Aggregations