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 2007/05/25 21:46:19 UTC

Nested struts forms, dynamic allocation using javascript or ??

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

Hi folks,

I've taken more than a couple stabs at trying to do this and failed.
Miserably enough that I'm not going to even attempt to post my efforts
here.. they're really ugly.

What I'm trying to create is a form that folks that are not all that
computer literate can feel comfortable using to enter in events to be
added to a club's calendar of events. The first part of this task is
really straight forward in that I collect the name of the event, its
description and yadaydaydada...

Here's where it gets hairy and the idea of using nested forms came to mind:

The events can have at least one day but can be over more than one day
with each day possibly having a different start time and finish time.

To that end I have a bean:

public class EventDayBean {
	private Date start_time;
	private Date end_time;
	private Date event_day;
   |
   |
   /* getters/setters follow **/
};

that will be included in the action form as a collection (ArrayList).

Given that each event will have at least one day I want to either

a) have a field where they user inputing the data specifies how many
days the event is and have some mechanism to (re)populate the nested
portion of the form (growing/shrinking  the collection as needed) or

b) have a button that says "add day"

or ??

What I'm interested in here is input from those that might have
implemented such a thing as to what strategies are viable to solve this.

Thanks in advance for your thoughts....

- ---
Peter L. Berghold                                  Unix Professional
Peter@Berghold.Net             AIM: redcowdawg YIM: blue_cowdawg
"Those who fail to learn from history are condemned to repeat it."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGVz0LUM9/01RIhaARAp3OAKCm8T2HbIyulfXE5iP0g4fhJ6ug4gCePgip
Lg+Jd2YeiopAdDPlj/oGwDE=
=MbDu
-----END PGP SIGNATURE-----

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


RE: Nested struts forms, dynamic allocation using javascript or ??

Posted by "Forsberg, Mike" <mi...@amd.com>.
Something you might consider, the Date object not only contains the
time, but also the date.

Joda - http://joda-time.sourceforge.net/ - is a good API for time
structures.  Far superior to the Date class in Java, because it has:
- LocalTime class that represents time only.
- Period class for representing periods of time
- others

I find that if the Business Objects are architected correctly the
presentation layer, the form, becomes self describing.

Hope I helped,

Big Mike
-----Original Message-----
From: Peter L. Berghold [mailto:peter@berghold.net] 
Sent: Friday, May 25, 2007 2:46 PM
To: Struts Users Mailing List
Subject: Nested struts forms, dynamic allocation using javascript or ??

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

Hi folks,

I've taken more than a couple stabs at trying to do this and failed.
Miserably enough that I'm not going to even attempt to post my efforts
here.. they're really ugly.

What I'm trying to create is a form that folks that are not all that
computer literate can feel comfortable using to enter in events to be
added to a club's calendar of events. The first part of this task is
really straight forward in that I collect the name of the event, its
description and yadaydaydada...

Here's where it gets hairy and the idea of using nested forms came to
mind:

The events can have at least one day but can be over more than one day
with each day possibly having a different start time and finish time.

To that end I have a bean:

public class EventDayBean {
	private Date start_time;
	private Date end_time;
	private Date event_day;
   |
   |
   /* getters/setters follow **/
};

that will be included in the action form as a collection (ArrayList).

Given that each event will have at least one day I want to either

a) have a field where they user inputing the data specifies how many
days the event is and have some mechanism to (re)populate the nested
portion of the form (growing/shrinking  the collection as needed) or

b) have a button that says "add day"

or ??

What I'm interested in here is input from those that might have
implemented such a thing as to what strategies are viable to solve this.

Thanks in advance for your thoughts....

- ---
Peter L. Berghold                                  Unix Professional
Peter@Berghold.Net             AIM: redcowdawg YIM: blue_cowdawg
"Those who fail to learn from history are condemned to repeat it."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGVz0LUM9/01RIhaARAp3OAKCm8T2HbIyulfXE5iP0g4fhJ6ug4gCePgip
Lg+Jd2YeiopAdDPlj/oGwDE=
=MbDu
-----END PGP SIGNATURE-----

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






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


RE: Nested struts forms, dynamic allocation using javascript or ??

Posted by "Jiang, Peiyun " <Pe...@nrc-cnrc.gc.ca>.
I don't have any working code now, but I think you can do it like this:

(1) add your list as an array on the form.
	private YourBean[] yourlist = null;

	public YourBean[] getYourlist() {
		return yourlist;
	}

	public void setYourlist(YourBean[] yourlist) {
		this.yourlist = yourlist;
	}

	public YourBean getYourlistIndexed(int index) {
		return yourlist[index];
	}

	public void setYourlistIndexed(int index, YourBean yourBean) {
		yourlist[index] = yourBean;
	}

(2) display on page using tags
<logic:iterate name="form" property="yourlist" id="oneOfThem"
indexId="ct">
	<tr>
	   <td><html:text name="form"
property="yourlistIndexed[${ct1}].field1" /></td>
	   <td><html:text name="form"
property="yourlistIndexed[${ct1}].field2" /></td>
	</tr>
</logic:iterate>

(3) manipulate yourlist in Action.

Peiyun
 

-----Original Message-----
From: Peter L. Berghold [mailto:peter@berghold.net] 
Sent: May 25, 2007 3:46 PM
To: Struts Users Mailing List
Subject: Nested struts forms, dynamic allocation using javascript or ??

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

Hi folks,

I've taken more than a couple stabs at trying to do this and failed.
Miserably enough that I'm not going to even attempt to post my efforts
here.. they're really ugly.

What I'm trying to create is a form that folks that are not all that
computer literate can feel comfortable using to enter in events to be
added to a club's calendar of events. The first part of this task is
really straight forward in that I collect the name of the event, its
description and yadaydaydada...

Here's where it gets hairy and the idea of using nested forms came to
mind:

The events can have at least one day but can be over more than one day
with each day possibly having a different start time and finish time.

To that end I have a bean:

public class EventDayBean {
	private Date start_time;
	private Date end_time;
	private Date event_day;
   |
   |
   /* getters/setters follow **/
};

that will be included in the action form as a collection (ArrayList).

Given that each event will have at least one day I want to either

a) have a field where they user inputing the data specifies how many
days the event is and have some mechanism to (re)populate the nested
portion of the form (growing/shrinking  the collection as needed) or

b) have a button that says "add day"

or ??

What I'm interested in here is input from those that might have
implemented such a thing as to what strategies are viable to solve this.

Thanks in advance for your thoughts....

- ---
Peter L. Berghold                                  Unix Professional
Peter@Berghold.Net             AIM: redcowdawg YIM: blue_cowdawg
"Those who fail to learn from history are condemned to repeat it."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGVz0LUM9/01RIhaARAp3OAKCm8T2HbIyulfXE5iP0g4fhJ6ug4gCePgip
Lg+Jd2YeiopAdDPlj/oGwDE=
=MbDu
-----END PGP SIGNATURE-----

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


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