struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ahearn, Denis" <DEN...@firepond.com>
Subject Problem using nested property names with DynaActionForm - Should Struts support this?
Date Wed, 20 Nov 2002 21:33:31 GMT
Hi,

I am trying to use a nested property with a DynaActionForm, as shown below:

	<form-bean name="personForm" dynamic="true"
type=type="org.apache.struts.action.DynaActionForm">
                <form-property name="address.zipCode"
type="java.lang.String"/>
	</form-bean>

In my JSP file, I use the html:text tag to bind the form property to an HTML
text element:

	<html:text property="address.zipCode" maxlength="5"/>

When I access this JSP page, I get the following error:

javax.servlet.ServletException: No getter method for property
address.zipCode of bean org.apache.struts.taglib.html.BEAN
    	at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:494)
	at
org.apache.jsp.SG_0002dcensus_form_jsp._jspService(SG_0002dcensus_form_jsp.j
ava:389)
	at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
04)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

>From what I can tell, when Struts creates an instance of DynaActionForm for
this form definition, it creates a property on the form named
"address.zipCode".  However, the html:text tag treats the propertyName as a
nested property, and expects the bean supplied to it (the form) to contain a
property named "address" which in turn has a property named "zipCode".
Since the form doesn't have an "address" property, the exception results.

Apparently Struts does not support nested property names with the
<form-property> tag.  Would the Struts developers consider enhancing
DynaActionForm and DynaActionFormClass to support this usage?  I believe all
it would take is enhancing those two classes to create the necessary object
hierarchy for nested properties, using DynaBeans for the child objects.

Thanks,
Denis

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message