• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / displaytag / 1753

12 Feb 2026 03:17AM UTC coverage: 77.321% (-0.01%) from 77.334%
1753

push

github

web-flow
Merge pull request #1102 from hazendaz/renovate/javax-support-logback-monorepo

Update dependency ch.qos.logback:logback-classic to v1.5.29 (javax-support)

1438 of 2003 branches covered (71.79%)

Branch coverage included in aggregate %.

4034 of 5074 relevant lines covered (79.5%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.96
/displaytag/src/main/java/org/displaytag/localization/I18nSpringAdapter.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2002-2026 Fabrizio Giustina, the Displaytag team
6
 */
7
package org.displaytag.localization;
8

9
import java.util.Locale;
10

11
import javax.servlet.http.HttpServletRequest;
12
import javax.servlet.jsp.PageContext;
13
import javax.servlet.jsp.tagext.Tag;
14

15
import org.displaytag.Messages;
16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
18
import org.springframework.context.MessageSource;
19
import org.springframework.web.servlet.support.RequestContextUtils;
20

21
/**
22
 * Spring implementation of a resource provider and locale resolver. Since Displaytag locale resolution is modelled on
23
 * the Spring one, it simply forward <code>resolveLocale</code> calls to the Spring-configured LocaleResolver.
24
 */
25
public class I18nSpringAdapter implements LocaleResolver, I18nResourceProvider {
1✔
26

27
    /**
28
     * prefix/suffix for missing entries.
29
     */
30
    public static final String UNDEFINED_KEY = "???"; //$NON-NLS-1$
31

32
    /**
33
     * logger.
34
     */
35
    private static Logger log = LoggerFactory.getLogger(I18nSpringAdapter.class);
1✔
36

37
    /**
38
     * Resolve locale.
39
     *
40
     * @param pageContext
41
     *            the page context
42
     *
43
     * @return the locale
44
     *
45
     * @see LocaleResolver#resolveLocale(PageContext)
46
     */
47
    @Override
48
    public Locale resolveLocale(final PageContext pageContext) {
49
        return RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest());
1✔
50
    }
51

52
    /**
53
     * Gets the resource.
54
     *
55
     * @param resourceKey
56
     *            the resource key
57
     * @param defaultValue
58
     *            the default value
59
     * @param tag
60
     *            the tag
61
     * @param pageContext
62
     *            the page context
63
     *
64
     * @return the resource
65
     *
66
     * @see I18nResourceProvider#getResource(String, String, Tag, PageContext)
67
     */
68
    @Override
69
    public String getResource(final String resourceKey, final String defaultValue, final Tag tag,
70
            final PageContext pageContext) {
71
        final MessageSource messageSource = RequestContextUtils
1✔
72
                .findWebApplicationContext((HttpServletRequest) pageContext.getRequest());
1✔
73
        if (messageSource == null) {
1!
74
            I18nSpringAdapter.log.warn("messageSource not found");
×
75
            return null;
×
76
        }
77

78
        // if resourceKey isn't defined either, use defaultValue
79
        final String key = resourceKey != null ? resourceKey : defaultValue;
1✔
80

81
        String message;
82

83
        message = messageSource.getMessage(key, null, null,
1✔
84
                RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest()));
1✔
85

86
        // if user explicitly added a titleKey we guess this is an error
87
        if (message == null && resourceKey != null) {
1✔
88
            I18nSpringAdapter.log.debug(Messages.getString("Localization.missingkey", resourceKey)); //$NON-NLS-1$
1✔
89
            message = I18nSpringAdapter.UNDEFINED_KEY + resourceKey + I18nSpringAdapter.UNDEFINED_KEY;
1✔
90
        }
91

92
        return message;
1✔
93

94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc