|
From: Guillaume P. <gpo...@gl...> - 2004-03-05 16:05:54
|
CustomEditorConfigurer only registers the PropertyEditors for the current= factory=2C not the whole JVM=2E ---- Messages d=B4origine ---- De=3A Alef Arendsen =3Calef=40jteam=2Enl=3E Date=3A vendredi=2C mars 5=2C 2004 10=3A37 am Objet=3A RE=3A =5BSpringframework-developer=5D =22permanantly=22 register= ing property editor with BeanWrapper=3F =3E It=27s not possible to do this via a static on the BeanWrapper=2E It = =3E IS possible =3E however=2E=2E=2E =3E = =3E J=FCrgen added a CustomEditorConfigurer that you can use to do this=2E= = =3E Just add =3E it to you app context and you=27re done=2E =3E = =3E =3C!-- taken from JavaDOC --=3E =3E =3Cbean id=3D=22customEditorConfigurer=22 =3E class=3D=22org=2Espringframework=2Ebeans=2Efactory=2Econfig=2ECustomE= ditorConfigurer=22=3E =3E =3Cproperty name=3D=22customEditors=22=3E =3E =3Cmap=3E =3E =3Centry key=3D=22java=2Eutil=2EDate=22=3E =3E =3Cbean class=3D=22mypackage=2EMyCustomDateEditor=22/=3E =3E =3C/entry=3E =3E =3Centry key=3D=22mypackage=2EMyObject=22=3E =3E =3Cbean id=3D=22myEditor=22 class=3D=22mypackage=2EMObjectEdit= or=22=3E =3E =3Cproperty name=3D=22myParam=22=3E=3Cvalue=3EmyValue=3C/val= ue=3E=3C/property=3E =3E =3C/bean=3E =3E =3C/entry=3E =3E =3C/map=3E =3E =3C/property=3E =3E =3C/bean=3E =3E = =3E If you=27re programmatically using the BeanFactory=2C you can add =3E propertyeditors using registerCustomEditor from the BeanFactory = =3E (or use a =3E BeanFactoryPostProcessor)=2E =3E = =3E Alef =3E = =3E = =3E =3E -----Original Message----- =3E =3E From=3A springframework-developer-admin=40lists=2Esourceforge=2En= et =3E =3E =5Bmailto=3Aspringframework-developer-admin=40lists=2Esourceforge= =2Enet=5D = =3E On Behalf =3E =3E Of Chris Winters =3E =3E Sent=3A Friday=2C March 05=2C 2004 4=3A17 PM =3E =3E To=3A Spring-Dev =3E =3E Subject=3A =5BSpringframework-developer=5D =22permanantly=22 regi= stering = =3E property=3E editor with BeanWrapper=3F =3E =3E = =3E =3E Is there a way to permanantly (for the life of the current JVM =3E =3E instance) register a property editor for the BeanWrapper =3E =3E (BeanWrapperImpl) to use=3F I see it maintains a static map of =3E =3E =27defaultEditors=27 but it looks like custom editors have to be =3E =3E registered with each wrapper instance=2E =3E =3E = =3E =3E Would it be possible to add a=3A =3E =3E = =3E =3E static void registerCustomerEditor( Class c=2C PropertyEditor = e ) =3E =3E = =3E =3E or something similar that adds a custom editor to the default (or= =3E =3E global) editors=3F =3E =3E = =3E =3E Thanks=2C =3E =3E = =3E =3E Chris =3E =3E = =3E =3E -- =3E =3E Chris Winters (cwinters=40optiron=2Ecom) =3E =3E Senior Software Architect =3E =3E = =3E =3E = =3E =3E ------------------------------------------------------- =3E =3E This SF=2ENet email is sponsored by=3A IBM Linux Tutorials =3E =3E Free Linux tutorial presented by Daniel Robbins=2C President and = =3E CEO of =3E =3E GenToo technologies=2E Learn everything from fundamentals to syst= em =3E =3E = =3E administration=2Ehttp=3A//ads=2Eosdn=2Ecom/=3Fad=5Fid=3D1470=26alloc=5F= id=3D3638=26op=3Dclick=3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F =3E =3E Springframework-developer mailing list =3E =3E Springframework-developer=40lists=2Esourceforge=2Enet =3E =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/springframewor= k- =3E developer =3E = =3E = =3E ------------------------------------------------------- =3E This SF=2ENet email is sponsored by=3A IBM Linux Tutorials =3E Free Linux tutorial presented by Daniel Robbins=2C President and CEO = of =3E GenToo technologies=2E Learn everything from fundamentals to system =3E administration=2Ehttp=3A//ads=2Eosdn=2Ecom/=3Fad=5Fid=1470=26alloc=5F= id638=26op=D5ick =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F =3E Springframework-developer mailing list =3E Springframework-developer=40lists=2Esourceforge=2Enet =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/springframework-de= veloper =3E |
|
From: Guillaume P. <gpo...@gl...> - 2004-03-05 18:07:32
|
=3E I wouldn=27t know how to add additional custom editors to beanwrapper= s =3E instantiated manually=2E The solution Guillaume is suggesting (with = =3E Sun=27sPropertyManager) will not work=3B since Spring doesn=27t use i= t = =3E (securityrestrictions might give problems there)=2E That=27s not accurate=2E What Spring does not use (anymore)=2C is the Pr= opertyEditorManager to register its own PropertyEditor=2C in case the Sec= urityManager does not allows it=2E It=27s why there=27s a need for a def= aultEditors static Map=2E The method PropertyEditorManager=2EfindEditor(= Class requiredType) is used by Spring in the method that does the convers= ion=2C and that method would look for PropertyEditors in the two way I me= ntionned earlier=2C and also in the search path that I forgot to mention=2E= See the Javadoc of BeanWrapperImpl =3A =3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3E=3E=3E=3E=3E= =3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E * =3Cp=3ENote=3A Regards property editors in org=2Espringframework=2Ebea= ns=2Epropertyeditors=2E * Also explictly register the default ones to care for JREs that do not = use * the thread context class loader for editor search paths=2E * Applications can either use a standard PropertyEditorManager to regist= er a * custom editor before using a BeanWrapperImpl instance=2C or call the i= nstance=27s * registerCustomEditor method to register an editor for the particular i= nstance=2E =3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3C=3E=3E=3E=3E=3E= =3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E=3E The Javadoc is somewhat outdated thought=2C it does not add =22org=2Espri= ngframework=2Ebeans=2Epropertyeditors=22 to the search path anymore=2C bu= t add each of the editors in the defaultEditors=2E Previous version of t= he BeanWrapperImpl registered the search path=2C and added them to the ma= p just in case=2C and it was changed since to only use the defaultEditors= map for Spring=27s register=2C but that has no effect on Application=27s= Custom Editors=2E Guillaume ---- Messages d=B4origine ---- De=3A Alef Arendsen =3Calef=40jteam=2Enl=3E Date=3A vendredi=2C mars 5=2C 2004 11=3A19 am Objet=3A RE=3A =5BSpringframework-developer=5D =22permanantly=22 register= ing property editor with BeanWrapper=3F =3E Oops=2C I guess (no I don=27t guess=2C I know for sure =3B-) manually= = =3E instantiatinga BeanWrapperImpl won=27t give you the additional = =3E PropertyEditors registered =3E through CustomEditorConfigurer=2C if that=27s what you meant! The = =3E BeanWrapperdoesn=27t know of anything like an ApplicationContext = =3E when just instantiating =3E it=2E =3E = =3E I=27m using the BeanWrapperImpl in some rare cases as well (same = =3E reason=2C it=27s =3E really convenient)=2E =3E = =3E I wouldn=27t know how to add additional custom editors to beanwrapper= s =3E instantiated manually=2E The solution Guillaume is suggesting (with = =3E Sun=27sPropertyManager) will not work=3B since Spring doesn=27t use i= t = =3E (securityrestrictions might give problems there)=2E =3E = =3E Alef =3E = =3E =3E -----Original Message----- =3E =3E From=3A springframework-developer-admin=40lists=2Esourceforge=2En= et =3E =3E =5Bmailto=3Aspringframework-developer-admin=40lists=2Esourceforge= =2Enet=5D = =3E On Behalf =3E =3E Of Chris Winters =3E =3E Sent=3A Friday=2C March 05=2C 2004 4=3A58 PM =3E =3E To=3A springframework-developer=40lists=2Esourceforge=2Enet =3E =3E Subject=3A Re=3A =5BSpringframework-developer=5D =22permanantly=22= registering =3E =3E property editor with BeanWrapper=3F =3E =3E = =3E =3E Alef Arendsen wrote=3A =3E =3E =3E It=27s not possible to do this via a static on the BeanWrappe= r=2E = =3E It IS =3E =3E possible =3E =3E =3E however=2E=2E=2E =3E =3E =3E =3E =3E =3E J=FCrgen added a CustomEditorConfigurer that you can use to d= o = =3E this=2E Just =3E =3E add =3E =3E =3E it to you app context and you=27re done=2E =3E =3E =3E =3E =3E =3E =3C!-- taken from JavaDOC --=3E =3E =3E =3E =3Cbean id=3D=22customEditorConfigurer=22 =3E =3E =3E =2E=2E=2E =3E =3E = =3E =3E Excellent! That should work just fine=2E =3E =3E = =3E =3E =3E If you=27re programmatically using the BeanFactory=2C you can= add =3E =3E =3E propertyeditors using registerCustomEditor from the = =3E BeanFactory (or use =3E =3E a =3E =3E =3E BeanFactoryPostProcessor)=2E =3E =3E = =3E =3E This is what I started doing=2C but if I instantiate a =3E =3E BeanWrapperImpl myself the editors aren=27t available=2E (I=27m j= ust =3E =3E using the BeanWrapper as a shortcut to do some property mapping =3E =3E because it=27s so darned convenient=2E) =3E =3E = =3E =3E Plus I=27m not sure how to do this from an ApplicationContext vs=2E= a =3E =3E BeanFactory -- the registerCustomEditor() seems to be implemented= =3E =3E in AbstractBeanFactory which doesn=27t seem to be a parent of any= =3E =3E ApplicationContext class=2E (I=27m a little hazy on the relations= hips =3E =3E among the objects at this level tho=2E) =3E =3E = =3E =3E Thanks! =3E =3E = =3E =3E Chris =3E =3E = =3E =3E -- =3E =3E Chris Winters (cwinters=40optiron=2Ecom) =3E =3E Senior Software Architect =3E =3E = =3E =3E = =3E =3E ------------------------------------------------------- =3E =3E This SF=2ENet email is sponsored by=3A IBM Linux Tutorials =3E =3E Free Linux tutorial presented by Daniel Robbins=2C President and = =3E CEO of =3E =3E GenToo technologies=2E Learn everything from fundamentals to syst= em =3E =3E administration=2Ehttp=3A//ads=2Eosdn=2Ecom/=3Fad=5Fid=1470=26allo= c=5Fid638=26op=3Dick =3E =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =3E =3E Springframework-developer mailing list =3E =3E Springframework-developer=40lists=2Esourceforge=2Enet =3E =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/springframewor= k- =3E developer =3E = =3E = =3E ------------------------------------------------------- =3E This SF=2ENet email is sponsored by=3A IBM Linux Tutorials =3E Free Linux tutorial presented by Daniel Robbins=2C President and CEO = of =3E GenToo technologies=2E Learn everything from fundamentals to system =3E administration=2Ehttp=3A//ads=2Eosdn=2Ecom/=3Fad=5Fid=1470=26alloc=5F= id638=26op=D5ick =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F =3E Springframework-developer mailing list =3E Springframework-developer=40lists=2Esourceforge=2Enet =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/springframework-de= veloper =3E |