Hi,
I'm working on an application which manages groups of email addresses, and I came across this puzzling scenario ["Editing contact group" function]:
On clicking an "Edit" link, 2 hidden fields in a HTML form are set - 'groupId' to 2 (for example) and 'action' to "edit". The form ( ContactGroupForm) is then posted to ContactGroupAction. ContactGroupAction then checks to see if the action is "edit" and seeing that it is, returns a mapping.findForward("edit"), thus passing control to EditContactGroupAction (as shown in the action mappings below). At this point, there are NO request or session attributes set; the only place which contains the groupId and action is the HTML form, or rather, ContactGroupForm.
However, on examining the code of EditContactGroupAction and stepping through manually using the Eclipse debugger, I found that EditContactGroupForm that is passed into the execute method of EditContactGroupAction already has "groupId" and "action" fields initialised to the same values as ContactGroupForm!! I.e. the fields had the values 2 and "edit". The resulting presentation JSP page thus showed the prefilled fields of the contact group that I'm supposed to edit after clicking the link. Why is this so? Aren't the fields supposed to be null when EditContactGroupForm is first called by the action mapping for "editcontactgroup"?
I think it might be because the fields in both ActionForms share the same name, i.e. both ContactGroupForm and EditContactGroupForm have "groupId" and "action" fields, but nothing in the Struts documentation mentioned anything of this sort. Am I missing something?
<action path="/contactgroup" name="ContactGroupForm" type="com.actions.ContactGroupAction" scope="request" validate="true" input="/contactgroup"> <forward name="redirect" path="contactgroup.do"/> <forward name="edit" path="editcontactgroup.do"/> </action>
<action path="/editcontactgroup" name="EditContactGroupForm" type="com.actions.EditContactGroupAction" scope="request" validate="true" input="/editcontactgroup"> <forward name="redirect" path="editcontactgroup"/> <forward name="reload" path="editcontactgroup.do"/> <forward name="success" path="contactgroup.do"/> </action>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]