document.forms[0]["mybean.name"].value = "myname" ;
will work
[EMAIL PROTECTED] wrote:
I haven't tried it, however, I would have to see if JavaScript would handle it.
I am updating the hidden field using javascript, so I am not sure if it would
like:
<script language="JavaScript">
document.forms[0].myBean.name.value = "myname";
...
...
</script>
~K
Quoting Michael Jouravlev <[EMAIL PROTECTED]>:
Are you saying that combination of nested properties and dynaform does
not work for nested fields?
Have you tried this:
<html:hidden name="myForm" property="myBean.name"/>
<html:hidden name="myForm" property="myBean.password"/>
Michael.
On 9/21/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi All,
I am trying to find a way to populate a DynaActionForm after the form has
been
submitted. For example, I have the following:
public class MyBean implements serializable {
public String name, address;
public MyBean() {
name = new String();
address = new String();
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
}
public class MyAction extends BaseDispatchAction {
public ActionForward save(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
MyBean myBean = (MyBean)((DynaActionForm)form).get("MyBean");
// do some processing
((DynaActionForm)form).set("myBean", myBean);
return mapping.findForward(IConstants.SUCCESS_KEY);
}
}
<struts-config>
<form-beans>
<form-bean name="myForm" dynamic="true"
type="org.apache.struts.action.DynaActionForm">
<form-property name="myBean" type="com.test.MyBean"/>
</form-bean>
</form-beans>
<action-mappings>
<action path="/MyAction"
type="com.test.MyAction"
parameter="method"
name="myForm"
scope="request">
<forward name="Success" path="my.page" />
</action>
</action-mappings>
</struts-config>
# JSP Page
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
<title>Test</title>
</head>
<body>
<html:form action="/MyAction" method="post">
Hidden Test
<input type="submit" name="submit" value="submit"/>
<html:hidden property="????" value="myname"/>
<html:hidden property="????" value="myaddress"/>
</html:form>
</body>
</html>
I am not sure what to put in the "property" attribute in the html:hidden
area so
that it will populate MyBean in my DynaActionForm property. Please keep in
mind
that this is just a sample and I need to use the DynaActionForm and not
extend
the MyBean class to ActionForm. Any help or suggestion is much
appreciated.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]