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

Lukasz Lenart edited comment on WW-4703 at 10/28/16 5:50 AM:
-------------------------------------------------------------

Here is my example, I have simplified my business logic. 

{code:java}
public class MyAction extends ActionSupport implements ModelDriven, 
SessionAware, ServletRequestAware {
{
    private Map<String, Object> session;
    private HttpServletRequest request;
    private MyForm myForm;

    public void setSession(Map<String, Object> session){
        this.session = session;
    }
    
    public void setServletRequest(HttpServletRequest request) {
                this.request = request;
    }
        
        public MyForm getModel() {
        myForm = new MyForm();
                return myForm;
        }
        
         public String execute() {
            myForm.doSomething();
                session.put("MyForm", myForm);
                return "success";
        
        }
        
}


public class MyForm extends ActionSupport {
private String myLabel;
        public void doSomething(){
                myLabel =  getText("my.label.01");
        }

}
{code}


was (Author: billychk):
Here is my example, I have simplified my business logic. 

public class MyAction extends ActionSupport implements ModelDriven, 
SessionAware, ServletRequestAware {
{
    private Map<String, Object> session;
    private HttpServletRequest request;
    private MyForm myForm;

    public void setSession(Map<String, Object> session){
        this.session = session;
    }
    
    public void setServletRequest(HttpServletRequest request) {
                this.request = request;
    }
        
        public MyForm getModel() {
        myForm = new MyForm();
                return myForm;
        }
        
         public String execute() {
            myForm.doSomething();
                session.put("MyForm", myForm);
                return "success";
        
        }
        
}


public class MyForm extends ActionSupport {
private String myLabel;
        public void doSomething(){
                myLabel =  getText("my.label.01");
        }

}

> NullPointerException in ActionSupport when use ModelDriven
> ----------------------------------------------------------
>
>                 Key: WW-4703
>                 URL: https://issues.apache.org/jira/browse/WW-4703
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.5.5
>         Environment: Windows 7
> WebSphere 8.5
>            Reporter: billy
>             Fix For: 2.5.6
>
>
> When we use getText method in a ModelDriven's bean.  We got 
> NullPointerException in ActionSupport.  We found the variable "container" is 
> null when the bean is got from ModelDriven.getModel()
> Following is the exception stack:
> {noformat}
> java.lang.NullPointerException
>       at 
> com.opensymphony.xwork2.ActionSupport.getLocale(ActionSupport.java:68)
>       at 
> com.opensymphony.xwork2.TextProviderSupport.getLocale(TextProviderSupport.java:329)
>       at 
> com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:204)
>       at 
> com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:119)
>       at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:86)
> {noformat}
> Note: we are upgrading the project from 2.3.24.3 to 2.5.5. In version 
> 2.3.24.3 doesn't have this issue.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to