struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jiang, Peiyun " <Peiyun.Ji...@nrc-cnrc.gc.ca>
Subject RE: Nested struts forms, dynamic allocation using javascript or ??
Date Fri, 25 May 2007 20:06:16 GMT
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


Mime
View raw message