Upgrading from Struts 1.1 to Nightly build
I'm upgrading our application at work to the nightly build (20031020) of Struts in order to use the validwhen Validator. I found a few deprecations and errors in the process, so I thought I'd share to help others upgrade easier:
- ActionError has been deprecated in favor of ActionMessage. Likewise, ActionMessages.GLOBAL_MESSAGE replaces ActionErrors.GLOBAL_ERROR.
- Methods in ResponseUtils have been deprecated in favor of TagUtils' methods.
- RequestUtils.message has been deprecated in favor of TagUtils.message. Other methods include RequestUtils.lookup.
- Many of the methods in TagUtils aren't static (they where were in Request/ResponseUtils), so you have to create an instance of TagUtils. Anyone know the logic here?
- ValidatorResources.get deprecated in favor of ValidatorResources.getForm.
- ValidatorForm.getFieldMap() is gone, which no apparent replacement method (at least not in the JavaDocs).
- The Tiles' Controller interface's perform method has been deprecated in favor of execute. You gotta love this one - while perform has been deprecated, you must use it or you will get a compile error saying you must implement it (or declare your class abstract). Same goes for execute. So to upgrade, I had to implement both methods - where my perform method calls my execute method.
- org.apache.commons.lang.NumberUtils moved to org.apache.commons.lang.math.NumberUtils
- org.apache.commons.validator.ValidatorUtil moved to org.apache.commons.validator.util.ValidatorUtils
- stringToInt(java.lang.String) in org.apache.commons.lang.math.NumberUtils has been deprecated. Not according to the its JavaDoc.
Final tally - two deprecation errors that don't seem to have replacements (yet):
[javac] .../src/web/org/appfuse/webapp/filter/BreadCrumbFilter.java:182: warning: stringToInt(java.lang.String) in org.apache.commons.lang.math.NumberUtils has been deprecated [javac] int mSS = NumberUtils.stringToInt(temp); [javac] ^ [javac] .../src/web/org/appfuse/webapp/taglib/LabelTag.java:71: warning: getFieldMap() in org.apache.commons.validator.Form has been deprecated [javac] Field field = (Field) form.getFieldMap().get(fieldName);
Later: Thanks to Steve Raeburn (via the struts-dev mailing list), I now have no deprecation errors. NumberUtils.stringToInt(String) is now NumberUtils.toInt(String) and Form.getFieldMap().get(String) is now Form.getField(String). Thanks Steve!
Posted by Yann Cebron on October 20, 2003 at 05:59 PM MDT #
Posted by Jason W on October 21, 2003 at 01:01 PM MDT #