You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Peter L. Berghold" <Pe...@berghold.net> on 2006/10/13 20:16:14 UTC

Nested forms.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi folks,

I have a real newbie question here.

I've looked at various on line tutorials on this subject and for
whatever reason I can't seem to wrap my head around this. My questions
are two fold on this, but I'll start with what I'm sure is the simpler
of the two and maybe it will shed light on the harder one.

I am creating an application that is going to be an events calendar.
When entering the event the form looks (for starters) like this:

Event name: [text ]     Event Location [text] [drop down     ]
Event classification: [drop down]

Number of days: [text]

and there's where things get tricky.  I know the answer is a nested
form, but I'm not quite sure how.

If say a user says the event is three days long I want to present them
with another form (or maybe through the magic of Ajax the same form...
but that's for another time) that says:

Day 1       date: [ text  ]  start time [ text ]  end time [text]
Day 2       date: [ text  ]  start time [ text ]  end time [text]
Day 3       date: [ text  ]  start time [ text ]  end time [text]


Why? because it is conceivable for an event to have different starting
and ending times for each day.

Where I keep running into issues is how to "initialize" the nested form
bean such that I have an array of 3 days (EventDate objects in my setup)
between the two forms.

I'm probably overlooking something rather basic here, but then I've only
been playing around in Struts for just under a year... Any help,
pointers, pointers to web pages or whatever will be greatly appreciated.


- --
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold                                     Peter@Berghold.Net
"Those who fail to learn from history are condemned to repeat it."
AIM: redcowdawg        Yahoo IM: blue_cowdawg              ICQ: 11455958
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org

iD8DBQFFL9ftUM9/01RIhaARAsNcAJ9AblUb96Y1y2/0Y+Zm5bU8THyP2QCgya2s
Tu8qIuoJm1WqNFKhj8Z79OI=
=QBwR
-----END PGP SIGNATURE-----


Re: Nested forms.

Posted by Puneet Lakhina <pu...@gmail.com>.
On 10/14/06, Peter L. Berghold <Pe...@berghold.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Puneet Lakhina wrote:
> >
> >> This is where you could use indexed or mapped properties.
> >> http://struts.apache.org/1.x/struts-taglib/indexedprops.html
> >
> >> And as for generating this form.. Dont think you need full fledged
> >> AJAX.. DHTML javscript to generate the fields would do.Basically what
> >> your indexd or mapped  properties would do is allow you to use an
> >> ArrayList or HashMap so that you dont need to initialize the number of
> >> elements that you expect to recieve.
> >
> >
>
>
> OK... I've got that so far... and I have some nice event driven
> Javascript that grows/shrinks the number of form fields as need be. What
> I need to figure out next is when does the "reset" method of a
> ActionForm get called?
>
> Before the form is accessed?  After? During?


This might help you http://www.jguru.com/faq/view.jsp?EID=827776

- --
> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> Peter L. Berghold                                     Peter@Berghold.Net
> "Those who fail to learn from history are condemned to repeat it."
> AIM: redcowdawg        Yahoo IM: blue_cowdawg              ICQ: 11455958
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.6 (GNU/Linux)
> Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org
>
> iD8DBQFFL/PIUM9/01RIhaARAvT8AJ9Cw78spSPIigEHczjU5rVQ/vrbQgCggVTQ
> ojiNpS9UapFmRK8cxLBP/bY=
> =+4Hr
> -----END PGP SIGNATURE-----
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Puneet

Re: Nested forms.

Posted by "Peter L. Berghold" <Pe...@berghold.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Puneet Lakhina wrote:
> 
>> This is where you could use indexed or mapped properties.
>> http://struts.apache.org/1.x/struts-taglib/indexedprops.html
> 
>> And as for generating this form.. Dont think you need full fledged 
>> AJAX.. DHTML javscript to generate the fields would do.Basically what
>> your indexd or mapped  properties would do is allow you to use an
>> ArrayList or HashMap so that you dont need to initialize the number of
>> elements that you expect to recieve.
> 
> 


OK... I've got that so far... and I have some nice event driven
Javascript that grows/shrinks the number of form fields as need be. What
I need to figure out next is when does the "reset" method of a
ActionForm get called?

Before the form is accessed?  After? During?



- --
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold                                     Peter@Berghold.Net
"Those who fail to learn from history are condemned to repeat it."
AIM: redcowdawg        Yahoo IM: blue_cowdawg              ICQ: 11455958
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org

iD8DBQFFL/PIUM9/01RIhaARAvT8AJ9Cw78spSPIigEHczjU5rVQ/vrbQgCggVTQ
ojiNpS9UapFmRK8cxLBP/bY=
=+4Hr
-----END PGP SIGNATURE-----


Re: Nested forms.

Posted by Puneet Lakhina <pu...@gmail.com>.
On 10/13/06, Peter L. Berghold <Pe...@berghold.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi folks,
>
> I have a real newbie question here.
>
> I've looked at various on line tutorials on this subject and for
> whatever reason I can't seem to wrap my head around this. My questions
> are two fold on this, but I'll start with what I'm sure is the simpler
> of the two and maybe it will shed light on the harder one.
>
> I am creating an application that is going to be an events calendar.
> When entering the event the form looks (for starters) like this:
>
> Event name: [text ]     Event Location [text] [drop down     ]
> Event classification: [drop down]
>
> Number of days: [text]


This part seems to fit into normal properties of a form bean.

and there's where things get tricky.  I know the answer is a nested
> form, but I'm not quite sure how.
>
> If say a user says the event is three days long I want to present them
> with another form (or maybe through the magic of Ajax the same form...
> but that's for another time) that says:
>
> Day 1       date: [ text  ]  start time [ text ]  end time [text]
> Day 2       date: [ text  ]  start time [ text ]  end time [text]
> Day 3       date: [ text  ]  start time [ text ]  end time [text]


This is where you could use indexed or mapped properties.
http://struts.apache.org/1.x/struts-taglib/indexedprops.html

And as for generating this form.. Dont think you need full fledged  AJAX..
DHTML javscript to generate the fields would do.Basically what your indexd
or mapped  properties would do is allow you to use an ArrayList or HashMap
so that you dont need to initialize the number of elements that you expect
to recieve.

 Why? because it is conceivable for an event to have different starting and
> ending times for each day.
>
> Where I keep running into issues is how to "initialize" the nested form
> bean such that I have an array of 3 days (EventDate objects in my setup)
> between the two forms.
>
> I'm probably overlooking something rather basic here, but then I've only
> been playing around in Struts for just under a year... Any help,
> pointers, pointers to web pages or whatever will be greatly appreciated.
>
>
> - --
> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> Peter L. Berghold                                     Peter@Berghold.Net
> "Those who fail to learn from history are condemned to repeat it."
> AIM: redcowdawg        Yahoo IM: blue_cowdawg              ICQ: 11455958
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.6 (GNU/Linux)
> Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org
>
> iD8DBQFFL9ftUM9/01RIhaARAsNcAJ9AblUb96Y1y2/0Y+Zm5bU8THyP2QCgya2s
> Tu8qIuoJm1WqNFKhj8Z79OI=
> =QBwR
> -----END PGP SIGNATURE-----
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Puneet.
Hab viel Spass.