Richard,
It seems to me that this would be useful for run-time decisions about where to "send"
the form data. Perhaps if a low-level user and an admin should see the same html
form, but the ActionForm that handles the admin's work should be different. i.e.:
<c:choose>
<c:when test="${userIsAdmin}">
<c:set var="type" value="com.foo.Bar" />
</c:when>
<c:otherwise>
<c:set var="type" value="com.foo.BarSubClass" />
</c:otherwise>
</c:choose>
<html:form action="/myaction" scope="request" type="${type}" name="myform" />
<!-- HTML HERE -->
I'm not sure if the html:form can take dynamic params like that (never tried it!)
Regardless of the syntax, it seems like you could share the same JSP, subclass the
ActionForm, and save yourself from creating a ton of duplicate code. You'd probably
still have to add an ActionForm mapping in struts-config for each form, but at least
you'd have only one JSP and Action class. Perhaps changing the scope dynamically like
this could potentially change the ActionForm stored in the session as well? Did I
miss something?
Regards,
Glenn
-----Original Message-----
From: Richard Hightower [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 14, 2004 9:11 AM
To: Struts Users Mailing List
Subject: RE: low priority question about html:form
Oppsss
the code listig should read:
<html:form action="/myaction" scope="request" type="arcmind.MyForm"
name="myform"/>
-----Original Message-----
From: Richard Hightower [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 14, 2004 10:08 AM
To: Struts Users Mailing List
Subject: low priority question about html:form
I assert the following:
"You could override the ActionForm associated with this <html:form/> by
using the scope and type attribute. The scope specifies where to look for
the ActionForm, and the type specifies what type of ActionForm it is, i.e.,
the fully qualified Java classname. This technique is not used in practice
very often, but it is good to know that it exists."
Example,
<html:form action="/myaction" scope="request" type="arcmind.MyForm"/>
I've thought of a few reasons why you want to do this, but they seemed
fairly lame. Can someone give me a valid use case where you would need this
feature?
QUESTION: Why not just specify the Form in the action mapping?
The <html:form /> tag renders an HTML form. The <html:form/> is associated
with an action mapping by the action attribute. The action attribute
specifies the path of the action mapping. Therefore, when the user submits
the form the action associated with the ActionMapping will be invoked (if
the form is valid). It is interesting that this tag inspect the
ActionMapping and finds the ActionForm associated with the ActionMapping.
If the ActionForm is in scope, the property values of the ActionForm will be
rendered as the values in the HTML form field of the <html:form/>. In fact
if the ActionMapping has an error (e.g., points to in valid ActionForm), the
page with the <html:form/> will never display until you fix the
ActionMapping.
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]