I am trying to think through creating a page that allows the users to dynamically add "phone" form fields for a "contact" (Contact model has a collection on Phone objects). The method is similiar to this example: http://www.quackfuzed.com/demos/jQuery/dynamicField/generalUse.cfm
Where I am having trouble is how to implement validation on the collection of Phone objects and how to use addFieldError() in my Validation function so that "cssErrorClass" works correctly. I have googled around but have found bits and pieces with no clear answer. How does Struts 2 handle validating elements in a collection? I have written a bit of pseudo-code that might explain a bit more. Has anyone done something like this? Am I missing a simple solution? ::Model:: public class Contact { private Integer contactId; private Collection<Phone> phones; } ::Action:: public class ContactCreateAction extends ActionSupport implements Validateable { public void validateCreate() { // Validate Phone Entries Here for (Phone phone : contact.getPhones()) { if (phone.getNumber().length < 10) { addFieldError(??HOW??); } } } } ::JSP:: <!-- Display Phone Numbers --> <s:iterator var="phone" value="%{contact.phones}" status="rowstatus"> <s:textfield name="contact.phones" value="%{#phone.number}" cssErrorClass="ErrorDataField" /> </s:iterator> <!-- This section will also contain Javacript to add/remove phone fields on the page --> --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org