java - Struts 2 type converter issue -
i trying use custom type conversion property file action.
action class implementing modeldriven 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 have welcomeaction-conversion.properties
file parallel action class converter config as:
bean.rectangle=struts2.typeconverters.rectangletypeconverter
i tried putting key bean, rectangle etc not working, not using converter class.
if use @typeconverter
annotation or global converter working fine.
my struts 2 version 2.3.15.1, idea issue.
update: created issue https://issues.apache.org/jira/browse/ww-4249
got correct way implementation: http://www.journaldev.com/2221/struts-2-ognl-tutorial-with-custom-type-converter-example
if action class using model driven need follow methodology custom type convertor:
http://struts.apache.org/release/2.3.x/docs/type-conversion.html (see section titled applying type converter bean or model).
in example changed conversion properties file name myjavabean-conversion.properties , placed under same package myjavabean.java.
in myjavabean-conversion.properties changed key to:
rectangle=com.journaldev.struts2.typeconverters.rectangletypeconverter
i built .war file , ran example under tomcat 7. rectangle conversion worked correctly.
i don't think ever use methodology explained @ http://struts.apache.org/release/2.3.x/docs/type-conversion.html (see section titled applying type converter action) when action class using modeldriven. if find previous struts 2 version did work let me know.
bruce phillips
Comments
Post a Comment