Java Code Examples for org.springframework.context.ApplicationContext.getMessage()

The following are Jave code examples for showing how to use getMessage() of the org.springframework.context.ApplicationContext class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: JuniperBotJ   File: CommandTag.java   View Source Code Vote up 6 votes
@Override
protected int doStartTagInternal() throws Exception {
    try {
        String result = code;
        Long serverId = (Long) pageContext.getRequest().getAttribute("serverId");
        if (serverId != null) {
            Locale locale = (Locale) pageContext.getAttribute(LOCALE_ATTR);
            ApplicationContext context = getRequestContext().getWebApplicationContext();
            if (locale == null) {
                ContextService contextService = context.getBean(ContextService.class);
                locale = contextService.getLocale(serverId);
                pageContext.setAttribute(LOCALE_ATTR, locale);
            }
            result = context.getMessage(code, null, locale);
        }
        if (StringUtils.isNotEmpty(var)) {
            pageContext.setAttribute(var, result);
        } else {
            JspWriter out = pageContext.getOut();
            out.write(result);
        }
    } catch (Exception ex) {
        throw new JspException(ex);
    }
    return SKIP_BODY;
}