• 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

0.0
/displaytag/src/main/java/org/displaytag/localization/I18nStruts2Adapter.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 com.opensymphony.xwork2.ActionContext;
10
import com.opensymphony.xwork2.LocaleProvider;
11
import com.opensymphony.xwork2.TextProvider;
12
import com.opensymphony.xwork2.util.ValueStack;
13

14
import java.util.Iterator;
15
import java.util.Locale;
16

17
import javax.servlet.jsp.PageContext;
18
import javax.servlet.jsp.tagext.Tag;
19

20
import org.apache.struts2.views.jsp.TagUtils;
21
import org.displaytag.Messages;
22
import org.slf4j.Logger;
23
import org.slf4j.LoggerFactory;
24

25
/**
26
 * Resolve i18n resources in Struts 2.
27
 *
28
 * @since Jan 4, 2008 2:37:29 PM
29
 */
30
public class I18nStruts2Adapter implements LocaleResolver, I18nResourceProvider {
×
31

32
    /**
33
     * prefix/suffix for missing entries.
34
     */
35
    public static final String UNDEFINED_KEY = "???"; //$NON-NLS-1$
36

37
    /**
38
     * logger.
39
     */
40
    private static Logger log = LoggerFactory.getLogger(I18nStruts2Adapter.class);
×
41

42
    /**
43
     * Resolve locale.
44
     *
45
     * @param pageContext
46
     *            the page context
47
     *
48
     * @return the locale
49
     *
50
     * @see LocaleResolver#resolveLocale(PageContext)
51
     */
52
    @Override
53
    public Locale resolveLocale(final PageContext pageContext) {
54

55
        Locale result = null;
×
56
        final ValueStack stack = ActionContext.getContext().getValueStack();
×
57

58
        final Iterator<Object> iterator = stack.getRoot().iterator();
×
59
        while (iterator.hasNext()) {
×
60
            final Object o = iterator.next();
×
61

62
            if (o instanceof LocaleProvider) {
×
63
                final LocaleProvider lp = (LocaleProvider) o;
×
64
                result = lp.getLocale();
×
65

66
                break;
×
67
            }
68
        }
×
69

70
        if (result == null) {
×
71
            I18nStruts2Adapter.log.debug("Missing LocalProvider actions, init locale to default");
×
72
            result = Locale.getDefault();
×
73
        }
74

75
        return result;
×
76
    }
77

78
    /**
79
     * Gets the resource.
80
     *
81
     * @param resourceKey
82
     *            the resource key
83
     * @param defaultValue
84
     *            the default value
85
     * @param tag
86
     *            the tag
87
     * @param pageContext
88
     *            the page context
89
     *
90
     * @return the resource
91
     *
92
     * @see I18nResourceProvider#getResource(String, String, Tag, javax.servlet.jsp.PageContext)
93
     */
94
    @Override
95
    public String getResource(final String resourceKey, final String defaultValue, final Tag tag,
96
            final PageContext pageContext) {
97

98
        // if resourceKey isn't defined either, use defaultValue
99
        final String key = resourceKey != null ? resourceKey : defaultValue;
×
100

101
        String message = null;
×
102
        final ValueStack stack = TagUtils.getStack(pageContext);
×
103
        final Iterator<Object> iterator = stack.getRoot().iterator();
×
104

105
        while (iterator.hasNext()) {
×
106
            final Object o = iterator.next();
×
107

108
            if (o instanceof TextProvider) {
×
109
                final TextProvider tp = (TextProvider) o;
×
110
                message = tp.getText(key, null, (String) null);
×
111

112
                break;
×
113
            }
114
        }
×
115

116
        // if user explicitly added a titleKey we guess this is an error
117
        if (message == null && resourceKey != null) {
×
118
            I18nStruts2Adapter.log.debug(Messages.getString("Localization.missingkey", resourceKey)); //$NON-NLS-1$
×
119
            message = I18nStruts2Adapter.UNDEFINED_KEY + resourceKey + I18nStruts2Adapter.UNDEFINED_KEY;
×
120
        }
121

122
        return message;
×
123
    }
124

125
}
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