struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukasz Lenart (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4740) NullPointer in com.opensymphony.xwork2.ActionSupport.getLocale
Date Mon, 13 Feb 2017 11:14:41 GMT

    [ https://issues.apache.org/jira/browse/WW-4740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15863484#comment-15863484
] 

Lukasz Lenart commented on WW-4740:
-----------------------------------

Sorry for that but I want to use DI as much as possible to get rid of those static methods
flying around. You can always use {{container}} to inject dependencies, in an action it can
be like this:

{code:java}
public String execute() throws Exception {
    ListGenerator generator = container.inject(ListGenerator.class);
    ....
}
{code}


> NullPointer in com.opensymphony.xwork2.ActionSupport.getLocale
> --------------------------------------------------------------
>
>                 Key: WW-4740
>                 URL: https://issues.apache.org/jira/browse/WW-4740
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.5.10
>            Reporter: Markus Fischer
>             Fix For: 2.5.next
>
>
> After upgrading from 2.5.2 to 2.5.10 I get a NullPointerException when calling getText("myKey")
in an utility class like this:
> {code:title=Example|borderStyle=solid}
> public class ListGenerator extends ActionSupport {
>     public final List<String> getValues() {
>         final List<String> result = new ArrayList<>();
>         result.add(getText("select.header"));
>         result.add(getText("register.female"));
>         result.add(getText("register.male"));
>         return result;
>     }
> }
> {code}
> java.lang.NullPointerException at com.opensymphony.xwork2.ActionSupport.getLocale(ActionSupport.java:64)
> ....
> ERROR org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler - Exception occurred
during processing request: java.lang.NullPointerException



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message