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 08:39:46 UTC

Loading complex forms with Struts.

Hi all,

I have a form within a page that I need struts to populate in a specific
manner.  The data selection within the page is as follows:

A variable number of subsystems, that can be independently selected.
Each subsystem has a time selection (single) and signal selection (one to
many).

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?
2) Can struts handle loading form beans in this manner?

Any help will, as always, be met with glowing praise and no money :-)

Cheers

Simon

Institut fuer
Prozessdatenverarbeitung
und Elektronik,
Forschungszentrum Karlsruhe GmbH,
Postfach 3640,
D-76021 Karlsruhe,
Germany.

Tel: (+49)/7247 82-4042
E-mail : kelly@ipe.fzk.de


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


Re: Loading complex forms with Struts.

Posted by Vic Cekvenich <vc...@basebeans.com>.
Master detail processing is done all the time in HTML and Struts.
One way is to have a bean that contains another bean as property via 
getBeanX().
.V

Simon Kelly wrote:
> Hi all,
> 
> I have a form within a page that I need struts to populate in a specific
> manner.  The data selection within the page is as follows:
> 
> A variable number of subsystems, that can be independently selected.
> Each subsystem has a time selection (single) and signal selection (one to
> many).
> 
> 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?
> 2) Can struts handle loading form beans in this manner?
> 
> Any help will, as always, be met with glowing praise and no money :-)
> 
> Cheers
> 
> Simon
> 
> Institut fuer
> Prozessdatenverarbeitung
> und Elektronik,
> Forschungszentrum Karlsruhe GmbH,
> Postfach 3640,
> D-76021 Karlsruhe,
> Germany.
> 
> Tel: (+49)/7247 82-4042
> E-mail : kelly@ipe.fzk.de



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


Re: Loading complex forms with Struts.

Posted by Simon Kelly <ke...@ipe.fzk.de>.
Thanks for that Kevin.  That's pretty much what I came up with as well.

The only addition I am making is that, to make sure all of the additional
selection information is grouped correctly, and to keep away from multiple
forms is to use the x.y.z naming method to reference every thing, so:

A subsystem check box will just have the name of the subsystem (They ar all
unique), the timestamp selection for each subsytem will have the name
subsytem.timestamp, and then the siganls will be subsystem.signalname, as
all signal names within a sub system will be unique as well.

With this aproach, I can have just one VO helper, and then this can load a
selection of subsytem VOs prior to passing them deeper into the business
logic or out to the view.

Cheers, and thanks again for the comment,

Simon

----- Original Message -----
From: "Kevin Williams" <kw...@tarity.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, March 14, 2003 5:56 PM
Subject: Re: Loading complex forms with Struts.


> Simon,
>
> What I've done (and I haven't tested it yet since I'm still coding
> supporting stuff so I'm not sure if it works) is to have an array
> property within my form bean.  This would hold the id's for the selected
> subsystem.  Within your jsp page, make sure all the checkboxes have the
> same name, and it should populate that array with the same name as the
> checkboxes in your form bean.
>
> I'm hoping this works for me!
>
> Kevin
>
> On Thu, 2003-03-13 at 23:39, Simon Kelly wrote:
> > Hi all,
> >
> > I have a form within a page that I need struts to populate in a specific
> > manner.  The data selection within the page is as follows:
> >
> > A variable number of subsystems, that can be independently selected.
> > Each subsystem has a time selection (single) and signal selection (one
to
> > many).
> >
> > 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?
> > 2) Can struts handle loading form beans in this manner?
> >
> > Any help will, as always, be met with glowing praise and no money :-)
> >
> > Cheers
> >
> > Simon
> >
> > Institut fuer
> > Prozessdatenverarbeitung
> > und Elektronik,
> > Forschungszentrum Karlsruhe GmbH,
> > Postfach 3640,
> > D-76021 Karlsruhe,
> > Germany.
> >
> > Tel: (+49)/7247 82-4042
> > E-mail : kelly@ipe.fzk.de
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>


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


Re: Loading complex forms with Struts.

Posted by Kevin Williams <kw...@tarity.com>.
Simon,

What I've done (and I haven't tested it yet since I'm still coding
supporting stuff so I'm not sure if it works) is to have an array
property within my form bean.  This would hold the id's for the selected
subsystem.  Within your jsp page, make sure all the checkboxes have the
same name, and it should populate that array with the same name as the
checkboxes in your form bean.

I'm hoping this works for me!

Kevin

On Thu, 2003-03-13 at 23:39, Simon Kelly wrote:
> Hi all,
> 
> I have a form within a page that I need struts to populate in a specific
> manner.  The data selection within the page is as follows:
> 
> A variable number of subsystems, that can be independently selected.
> Each subsystem has a time selection (single) and signal selection (one to
> many).
> 
> 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?
> 2) Can struts handle loading form beans in this manner?
> 
> Any help will, as always, be met with glowing praise and no money :-)
> 
> Cheers
> 
> Simon
> 
> Institut fuer
> Prozessdatenverarbeitung
> und Elektronik,
> Forschungszentrum Karlsruhe GmbH,
> Postfach 3640,
> D-76021 Karlsruhe,
> Germany.
> 
> Tel: (+49)/7247 82-4042
> E-mail : kelly@ipe.fzk.de
> 
> 
> ---------------------------------------------------------------------
> 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


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


Can struts handle multiple forms in a post + Partial answer to - [Re: Loading complex forms with Struts.]

Posted by Simon Kelly <ke...@ipe.fzk.de>.
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