I am trying to use the new DynaActionForm as my form bean.
I am having little bit of difficulty, when the properties are not primitive.
>From my understanding, there seems to be no way to initialize (or pre
create) a non-primitive property.
Without this, any subproperties of that bean will not be set.
My example:
I have an "html:image" type submit button, and when it is pressed, it posts
subproperties x and y.
To receive those, I created a simple bean "ImageInput" that has two
properties - x and y.
JSP:
<html:image property="imageSubmit" page="/images/submit.gif"/>
struts-config:
<form-bean>
<form-bean name="logonForm"
type="org.apache.struts.action.DynaActionForm">
<form-property name="username" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
<form-property name="imageSubmit" type="com.my.ImageInput" />
</form-bean>
I also tried, specifying the subproperties, thinking it might create the
initial instance so as to be
able to populate the subproperties.
<form-bean>
<form-bean name="logonForm"
type="org.apache.struts.action.DynaActionForm">
<form-property name="username" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
<form-property name="imageSubmit" type="com.my.ImageInput">
<set-property property="x" value="0"/>
<set-property property="y" value="0"/>
</form-property
</form-bean>
In neither case, "imageInput" property is populated.
So, I modified the code for "org.apache.struts.config.FormPropertyConfig" to
treat an empty value for "initial" to mean create the bean.
public Object initial() {
if (initial == null)
....
} else if (initial.length()==0){
Class clazz = Class.forName(type);
if (! clazz.isPrimitive()) {
initialValue = clazz.newInstance();
} else {
initialValue = ConvertUtils.convert(initial, clazz);
}
} else {
....
}
and the struts-config is changed to:
<form-property name="imageSubmit" type="com.my.ImageInput" initial="" />
Is this all necessary or did I miss something ?
If not, is there an alternate/better way of doing this ?
If this is an acceptable way of doing, would you consider taking this as a
patch.
Thanx in advance,
Anil
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>