Paul Benedict wrote:

I can use the copyProperties() method of the BeanUtils
to convert all the String(s) read from the web page to
proper Java "types" in my form bean.

Just be weary though, that BeanUtils can really by a major PAIN when you have domain objects that have number wrapper data types (Integer, Double, etc). BeanUtils has the VERY annoying behavior of converting null Strings to 0 for those number types. I end up always have to make Converters to deal with this and I really think BeanUtils should have a release that makes this NOT the default behavior. (Possibly provide some kind of extra param if you really want null to become 0).

Here's a test to demonstrate...

public class Test() {

 public static void main(String[] args) {
        Test test = new Test();
        test.doTest();
    }

private void doTest() {
        FormBean form = new FormBean();
        DomainBean bean = new DomainBean();

        try {
            BeanUtils.copyProperties(bean, form);
System.out.println("The string value of integer: "+ bean.getNumber() ); //0 !!!
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
    public class FormBean {
        private String number;

        public String getNumber() {
            return number;
        }

        public void setNumber(String number) {
            this.number = number;
        }
    }
    public class DomainBean {
        private Integer number;

        public Integer getNumber() {
            return number;
        }

        public void setNumber(Integer number) {
            this.number = number;
        }

    }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to