I upgraded one of my client's applications from Struts 1.1b2 to Struts 1.1b3 tonight. It was a small headache, but not too bad. As far as the differences b/w 1.1b2 and 1.1b3 - they're pretty significant. Some classes/methods are downright gone - not just deprecated, but gone. Oh well, that's why it's a beta - and it's free, so who's complaining? I'll try to remember a few issues I found. The first is how to create a DynaActionForm. The code below worked with 1.1b2:
DynaActionForm messageForm =
(DynaActionForm) DynaActionFormClass.getDynaActionFormClass(
Constants.MESSAGE_KEY).newInstance();
But the getDynaActionFormClass method is now gone, so you have to use this:
FormBeanConfig cfg =
mapping.getModuleConfig()
.findFormBeanConfig(Constants.MESSAGE_KEY);
DynaActionForm messageForm =
(DynaActionForm) DynaActionFormClass.createDynaActionFormClass(cfg)
.newInstance();
A few deprecation errors cropped up as well.
- Action.MESSAGE_KEY -> Globals.MESSAGE_KEY
- Action.ERROR_KEY -> Globals.ERROR_KEY
- org.apache.struts.validator.StrutsValidatorUtil -> org.apache.struts.validator.Resources
Finally, I found an issue with using BeanUtils.populate(dest, orig)
. It worked fine with 1.1b2, but throws a NPE with 1.1b3. I replaced this with BeanUtils.copyProperties(dest, orig)
and everything works as it should. My guess (from doing a toString() on the orig) is that "multipartRequestHandler=null" was messing things up.
It's interesting doing maintenance/enhancements on code that I wrote a year ago. I've learned sooooo much since then. I wish I could go back and re-factor a bunch, but my client would never go for it - it works right?! Maybe I'll refactor some for kicks - just to see if it's possible. I'd love to replace a few DAOMySQL's with DAOHibernate's ;-)
Anyone know of a utility that can be used to "remember" my CVS password? I can only access the server using SSH (similar to SourceForge) and it's getting to be a real pain to type my password every time.
After talking with Erik Hatcher a bit, I'm a bit worried about how I'm storing the current user's information. Basically, I'm putting a UserForm (extends ValidatorForm) into the session, and keeping it there to retrieve any user information I might need - in particular the userId. This is not the same as the user's login name, or the value I get from request.getRemoteUser(). How do you do this? I need the user's id from database lookups and filtering drop-downs, etc.
After working with Eclipse pretty heavily for the last week - I am beginning to become one of those guys that cannot live without an IDE. It's unfortunate in one sense, but it's great because it sure is saving me a lot of time. I love the "Organize Imports" feature, especially on the package level. Use it with caution if you've got generated classes - or add the generated classes to your classpath. I also really like the Jalopy Beautifier. I'm sure IDEA has these features too - if it doesn't, it should! Another cool plugin I found last week was one from the Eclipse team to hide CVS directories.
This morning, I found that the Hibernate team has released a new plugin for Eclipse - the Hibernator.
*** Hibernator - Hibernate plugin for Eclipse ***
Provides an Eclipse view to create and edit Hibernate mapping files (.hbm.xml).
Note this plugin will only work with Eclipse 2 (WSAD 5) and above
* Installation
- Unzip hibernator-0.9.zip into <eclipse-install>/plugins
- Restart Eclipse
* Using the plugin
Go to menu Window->Show View->Other and select Hibernator
Open up some Java source and the plugin will either display the mapping
file <class-name>.hbm.xml or a generated version
To save the contents of the mapping file right click in the window and
select "Save"
Report any bugs / Submit patches to - http://sourceforge.net/projects/hibernator.
I doubt I'll use this as I'm using XDoclet to generate my Hibernate mapping files from POJOs. However, the CodeGenerator for Hibernate is being re-vamped to allow for generation of .java files from an .hbm.xml file. Now if I could hook this into generation of Struts' ValidatorForms, I might actually use it.