You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Simon Kelly <ke...@ipe.fzk.de> on 2003/03/14 11:41:31 UTC
Can struts handle multiple forms in a post + Partial answer to - [Re: Loading complex forms with Struts.]
As an amendum to the question "Loading complex forms with Struts.". I have
found a solution and more problems :-(
> I need the data loaded into two beans, one for the Subsystem:
> String name;
> String time;
> List signals;
>
> And then one to hold all the subsystems:
> List subsystems;
>
> 1) I need to know if [OT] this can be written in html?
Html does not do forms in forms. But I have come accross a solution using
multiple forms and a small piece of java code to force all forms to submit
at the same time.
[FYI]
<!--
<script language="JavaScript">
function SubmitAll() {
document.form1.submit();
document.form2.submit();
....
document.formN.submit();
}
</script>
<form name="form1" ..../>
<form name="form2" .... />
....
<form name="formN" .... />
<input type="button" value="Submit" canClick="SubmitAll()" />
-->
HOWEVER
In struts-config the following action is required:
<action path="/formprocess"
name="form1"
scope="request"
validate="true"
type="com.test.action.FormProcessAction">
<forward name="success" path="/StrutsCXServlet"/>
<forward name="error" path="/idiot.do"/>
</action>
The question is, can a regexp be used to group all of the forms under the
one action (Such as name="form[1-9]")?? All the form names are dynamically
created, and unknown to struts before posting. Is there a way struts can
handle this sort of form posting?
Kind regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Can struts handle multiple forms in a post + Partial answer to - [Re: Loading complex forms with Struts.]
Posted by Nicolas De Loof <ni...@cgey.com>.
Be carreful, submiting your forms this way you will submit N request,
and only the last one will get a response. If others one have
validation or processing errors, you will not get them.
I would suggest you to set a new form with hidden fields, and
javascript to copy values. On submit, submit the hidden form :
<form name="copy" action="...">
<input type="hidden" name="name1">
<input type="hidden" name="nameN">
</form>
<form name="form1">
<input type="text"
onchange="document.forms.copy.name1.value=this.value">
</form>
<form name="formN">
<input type="text"
onchange="document.forms.copy.nameN.value=this.value">
</form>
This code can be easily built with some <logic:iterate>
Nico.
> [FYI]
> <!--
> <script language="JavaScript">
> function SubmitAll() {
> document.form1.submit();
> document.form2.submit();
> ....
> document.formN.submit();
> }
> </script>
> <form name="form1" ..../>
> <form name="form2" .... />
> ....
> <form name="formN" .... />
> <input type="button" value="Submit" canClick="SubmitAll()" />
> -->
>
> HOWEVER
> In struts-config the following action is required:
>
> <action path="/formprocess"
> name="form1"
> scope="request"
> validate="true"
> type="com.test.action.FormProcessAction">
> <forward name="success" path="/StrutsCXServlet"/>
> <forward name="error" path="/idiot.do"/>
> </action>
>
> The question is, can a regexp be used to group all of the forms
under the
> one action (Such as name="form[1-9]")?? All the form names are
dynamically
> created, and unknown to struts before posting. Is there a way
struts can
> handle this sort of form posting?
>
> Kind regards,
>
> Simon
>
>
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org