On Wed, 18 Apr 2001, James Howe wrote:
> I apologize in advance if this topic has come up before, but ...
>
> I'm building a Struts JSP page containing a form. I've noticed that the
> HTML tags typically do not require the specification of a "name" attribute
> in order to retrieve property values from a bean. If the name isn't
> specified, the property value is retrieved from the bean associated with
> the form. However, logic tags require the use of the name attribute in
> order to retrieve a property. Isn't there some way that the logic tags
> could look to see if there is a bean "in scope" and use that bean to
> retrieve property values from if no name attribute is specified? The
> problem I have is this, I have a portion of a form which is common to more
> than one form. I would like to factor out the common stuff into an include
> file of some sort. However, the common stuff makes use of a logic tag
> (notEqual). I can't factor out this code because I have to explicitly
> reference a specific bean name in order for this code to work. However, my
> various forms have different bean names associated with them. It's not a
> terribly big deal, but it seems as if the name attribute shouldn't have to
> be required if some sort of "default" bean is available for the page.
>
> Thanks.
>
>
The HTML-oriented tags that allow you to default the "name" attribute can
*only* be used within an <html:form> tag -- they are not useful in any
other context.
The logic tags (and the bean tags as well) are general purpose tools,
useful either inside or outside a form. It would be technically feasible
to do what you suggest, but IMHO it would be very confusing to have the
same tag do two different things depending on whether you nested it or
not.
Craig