You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Scott Van Wart <sc...@indosoft.com> on 2006/08/10 00:52:43 UTC

Map-based nested bean

(Struts 1.2.9, Tomcat 5.5.17)

I have something similar to the following in my ActionForm:

    public class MyForm extends ActionForm {

        public static class NestedBean {
            private String name;
            private String value;
            // String getName(), String getValue(), void setName( String 
), void setValue( String )
        }

        private Map<String, NestedBean> children = new TreeMap<String, 
NestedBean>();

        // Map getChildren(), void setChildren( Map )

        public NestedBean getChild( String key ) {
            return this.children.get( key );
        }

        public void setChild( String key, NestedBean child ) {
            this.children.put( key, child );
        }

    }

I use it like so in the JSP:

    <html:form action="/myAction">
        <html:text property="myForm.child(whatever).name" />
        <html:text property="myForm.child(whatever).value" />
    </html:form>

Everything works fine until form submission.  Then I get errors like "No 
bean specified" in the populate methods of BeanUtils.  Looking at the 
property descriptors I see that it's not picking up the getChild and 
setChild accessors.  Is this the right way to implement this?  Am I 
still missing something?

Thanks,
  Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org