Announcement Announcement Module
Collapse
No announcement yet.
Trouble mapping InternetAddress[] in form Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble mapping InternetAddress[] in form

    Hi,

    I subclassed SimpleFormController, and my commandClass looks like this:
    Code:
    import javax.mail.internet.InternetAddress;
    
    public class TellAFriendBean {
        private InternetAddress[] email;
        private String body;
    
        // accessors
    }
    My JSP has the following:
    Code:
    <spring&#58;bind path="bean.email&#91;0&#93;">
        ...
    </spring&#58;bind>
    When I post the form, I get an ArrayStoreException:
    Code:
    java.lang.ArrayStoreException
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;553&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;540&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;642&#41;
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues&#40;BeanWrapperImpl.java&#58;669&#41;
    	at org.springframework.validation.DataBinder.bind&#40;DataBinder.java&#58;208&#41;
    	at org.springframework.web.bind.ServletRequestDataBinder.bind&#40;ServletRequestDataBinder.java&#58;77&#41;
    	at org.springframework.web.servlet.mvc.BaseCommandController.bindAndValidate&#40;BaseCommandController.java&#58;257&#41;
    	at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal&#40;AbstractFormController.java&#58;235&#41;
    	at org.springframework.web.servlet.mvc.AbstractController.handleRequest&#40;AbstractController.java&#58;119&#41;
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle&#40;SimpleControllerHandlerAdapter.java&#58;45&#41;
    	at org.springframework.web.servlet.DispatcherServlet.doService&#40;DispatcherServlet.java&#58;389&#41;
    	at org.springframework.web.servlet.FrameworkServlet.serviceWrapper&#40;FrameworkServlet.java&#58;339&#41;
    	at org.springframework.web.servlet.FrameworkServlet.doPost&#40;FrameworkServlet.java&#58;325&#41;
    ...
    So, I added a PropertyEditor that knows how to transform a single String to InternetAddress, but that doesn't seem to help.

    Should I create a PropertyEditor that transforms from String[] to InternetAddress[] ?

    Thanks !
    François
Working...
X