20030106 Monday January 06, 2003

Upgrading to Struts 1.1b3 - Tips 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 ;-) Posted in Java at Jan 06 2003, 11:16:48 PM MST 6 Comments

Comments:

I really want to create a DynaActionForm from scratch. I have 1 dyna form being submitted, then depending upon what is in that form, I want to create a new form to then forward the user to the appropriate page, and use the values from this new DynaForm I created. How can I do this? I do not have access to the mapping object as your example describes as I am doing this operation in a Business Delegate and do not really want to pass the mapping object into this method.

Posted by Mick Knutson on February 10, 2003 at 10:23 PM MST #

It should be as simple as demonstrated - just replace <code>Constants.MESSAGE_KEY</code> with the name of your form in struts-config.xml.
FormBeanConfig cfg =
    mapping.getModuleConfig()
           .findFormBeanConfig("formNameFromStrutsConfig");

DynaActionForm messageForm =
    (DynaActionForm) DynaActionFormClass.createDynaActionFormClass(cfg)
                                        .newInstance();

Posted by Matt on February 11, 2003 at 04:43 AM MST #

Hi. I'm working in a personal project, and i'm using DynaValidatorActionForms, i don't know if what i will said is util for you, but here i go. I was so glass with DynaForms but when i needed to extend the DynaValidatorActionForms, and i tried to use my own Get Set methods on the jsp it dosen't found it.... What did i do? well what i'll gona do... ? So... i'll overwrite the initialize method to put new FormPropertyConfig beans to the FormBeanConfig... Do you think that it is a good idea?... Thks sorry for my bad english...

Posted by Hassan on December 13, 2004 at 04:18 PM MST #

Hi. I'm working in a personal project, and i'm using DynaValidatorActionForms, i don't know if what i will said is util for you, but here i go. I was so glass with DynaForms but when i needed to extend the DynaValidatorActionForms, and i tried to use my own Get Set methods on the jsp it dosen't found it.... What did i do? well what i'll gona do... ? So... i'll overwrite the initialize method to put new FormPropertyConfig beans to the FormBeanConfig... Do you think that it is a good idea?... Thks sorry for my bad english...

Posted by Hassan on December 13, 2004 at 04:18 PM MST #

Hi. I'm working in a personal project, and i'm using DynaValidatorActionForms, i don't know if what i will said is util for you, but here i go. I was so glass with DynaForms but when i needed to extend the DynaValidatorActionForms, and i tried to use my own Get Set methods on the jsp it dosen't found it.... What did i do? well what i'll gona do... ? So... i'll overwrite the initialize method to put new FormPropertyConfig beans to the FormBeanConfig... Do you think that it is a good idea?... Thks sorry for my bad english...

Posted by Hassan on December 13, 2004 at 04:40 PM MST #

Hi. I'm working in a personal project, and i'm using DynaValidatorActionForms, i don't know if what i will said is util for you, but here i go. I was so glass with DynaForms but when i needed to extend the DynaValidatorActionForms, and i tried to use my own Get Set methods on the jsp it dosen't found it.... What did i do? well what i'll gona do... ? So... i'll overwrite the initialize method to put new FormPropertyConfig beans to the FormBeanConfig... Do you think that it is a good idea?... Thks sorry for my bad english...

Posted by Hassan on December 13, 2004 at 04:41 PM MST #

Post a Comment:
  • HTML Syntax: Allowed
Click me to subscribe
Matt Raible is the Lead UI Architect at LinkedIn. The opinions on this site are mine, not my employers.
« November 2008
SunMonTueWedThuFriSat
      
1
2
3
6
7
8
9
10
11
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
      
Today

Recent Entries

Tag Cloud