Lance-

That works as long as you can pre-populate your field before clicking the editAction button. Recall that our "Add Field" button, via JavaScript, adds a new row to the table and by default the textfield is empty so the only way we would be able to retrieve the user's input would be to force them to click some sort of update button for that row after they enter some text in the text field - and I can tell you now, marketing will not go for that. :-)

However, we can use the editAction to delete a row and just make an AJAX call to modify the bean array in session scope (using a DynaActionForm) on the server without modifying the database.

-adam

Lance wrote:
I do this using 3 actions

loadAction - called first time the page is loaded, populates the form with
values from the db, the form has "session" scope.

editAction - called by a click on the add or delete button, adds or removes
a row from the form. Add and delete buttons should post to this action so
that any field changes will be picked up.

saveAction - commits the form to the db, called by a save button.

This means that clicking on add and save requires a page refresh but it
means struts will read input fields into your form automatically. Im sure
you could go the ajax way and add / delete from your ActionForm without
re-loading the page.

-----Original Message-----
From: Adam Gordon [mailto:[EMAIL PROTECTED] Sent: 31 July 2006 21:02
To: Struts Users Mailing List
Subject: Struts form design question

Hi folks.

The more I think of this problem, the more I think that we will be unable to
use only Struts for this particular situation.

We have a table which we populate with a user's choice of custom
registration fields (name, email, phone, company, etc...).  Each row in this
table is essentially a button to remove the row, a text field to enter the
name of the field, and a checkbox to indicate whether or not that particular
field is required when a user registers.  At the bottom of the table is an
"Add Field" button which will insert a new row in the table.
Right now, the "Add Field" and "Remove Row" buttons are implemented in
JavaScript because we don't want to edit the database every time the user
makes a change.  Additionally, we want the ability to "reset" the table back
to what the user had originally (the user's defaults can change over time,
and since they come from the database, this is why we don't want "live"
editing).

Initially creating the table isn't the problem, we can use DynaForms to
correctly create the table, the problem is how/can we read the values (the
rows of textfield/checkbox items) back when the user is finished editing
using Struts?  I don't think we can use DynaForms because the user can
change what was originally rendered...or am I misunderstanding DynaForms?

Thanks.

-Adam




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to