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] [Updated] (WW-4249) Custom Type Converter issue when Action class is implementing ModelDriven
Date Tue, 26 Nov 2013 07:04:35 GMT

     [ https://issues.apache.org/jira/browse/WW-4249?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Lukasz Lenart updated WW-4249:
------------------------------

    Description: 
I am trying to use custom type conversion with property file for action.

Action class is implementing ModelDriven for bean properties.
{code:java}
public class WelcomeAction extends ActionSupport implements ModelDriven<MyBean>{

    public String execute(){
        return SUCCESS;
    }

    private MyBean bean = new MyBean();

    @Override
        public MyBean getModel() {
        return bean;
    }
}
{code}
Bean class is:
{code:java}
public class MyBean{

    private Rectangle rectangle;
    public Rectangle getRectangle() {
        return rectangle;
    }

    public void setRectangle(Rectangle rectangle) {
        this.rectangle = rectangle;
    }
}
{code}

and I have WelcomeAction-conversion.properties file parallel to action class with converter
config as:
{noformat}
bean.rectangle=struts2.typeconverters.RectangleTypeConverter
{noformat}
I tried putting key as bean, rectangle etc but its not working, its not using converter class.

If i use @TypeConverter annotation or global converter then its working fine.

Complete Project: http://www.journaldev.com/2221/struts-2-ognl-tutorial-with-custom-type-converter-example
Project ZIP: http://cdn1.journaldev.com/wp-content/uploads/struts2/Struts2OGNLExample.zip
SO Question: http://stackoverflow.com/questions/18993091/struts-2-type-converter-issue

  was:
I am trying to use custom type conversion with property file for action.

Action class is implementing ModelDriven for bean properties.

public class WelcomeAction extends ActionSupport implements ModelDriven<MyBean>{

public String execute(){
    return SUCCESS;
}

private MyBean bean = new MyBean();

@Override
public MyBean getModel() {
    return bean;
}
}

Bean class is:

public class MyBean{

private Rectangle rectangle;
public Rectangle getRectangle() {
    return rectangle;
}

public void setRectangle(Rectangle rectangle) {
    this.rectangle = rectangle;
}
}

and I have WelcomeAction-conversion.properties file parallel to action class with converter
config as:

bean.rectangle=struts2.typeconverters.RectangleTypeConverter
I tried putting key as bean, rectangle etc but its not working, its not using converter class.

If i use @TypeConverter annotation or global converter then its working fine.

Complete Project: http://www.journaldev.com/2221/struts-2-ognl-tutorial-with-custom-type-converter-example
Project ZIP: http://cdn1.journaldev.com/wp-content/uploads/struts2/Struts2OGNLExample.zip
SO Question: http://stackoverflow.com/questions/18993091/struts-2-type-converter-issue


> Custom Type Converter issue when Action class is implementing ModelDriven
> -------------------------------------------------------------------------
>
>                 Key: WW-4249
>                 URL: https://issues.apache.org/jira/browse/WW-4249
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.3.15.1
>         Environment: Mac OS X 10.9 and Tomcat 7
>            Reporter: Pankaj Kumar
>              Labels: ognl, type-converter
>             Fix For: 2.3.17
>
>
> I am trying to use custom type conversion with property file for action.
> Action class is implementing ModelDriven for bean properties.
> {code:java}
> public class WelcomeAction extends ActionSupport implements ModelDriven<MyBean>{
>     public String execute(){
>         return SUCCESS;
>     }
>     private MyBean bean = new MyBean();
>     @Override
>         public MyBean getModel() {
>         return bean;
>     }
> }
> {code}
> Bean class is:
> {code:java}
> public class MyBean{
>     private Rectangle rectangle;
>     public Rectangle getRectangle() {
>         return rectangle;
>     }
>     public void setRectangle(Rectangle rectangle) {
>         this.rectangle = rectangle;
>     }
> }
> {code}
> and I have WelcomeAction-conversion.properties file parallel to action class with converter
config as:
> {noformat}
> bean.rectangle=struts2.typeconverters.RectangleTypeConverter
> {noformat}
> I tried putting key as bean, rectangle etc but its not working, its not using converter
class.
> If i use @TypeConverter annotation or global converter then its working fine.
> Complete Project: http://www.journaldev.com/2221/struts-2-ognl-tutorial-with-custom-type-converter-example
> Project ZIP: http://cdn1.journaldev.com/wp-content/uploads/struts2/Struts2OGNLExample.zip
> SO Question: http://stackoverflow.com/questions/18993091/struts-2-type-converter-issue



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message