Required vs. optional "name" attribute

2001-04-18 Thread James Howe

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.




Re: Required vs. optional "name" attribute

2001-04-18 Thread Rob Leland


James Howe wrote:
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.
The original designers were probably trying not to couple the logic
tags to the html tags, or to struts itself.

The name of the current form I believe is kept in the request variable

org.apache.struts.action.BEAN

so you can always confidently reference that for your logic 'name'
value.


> 
> Thanks.



Re: Required vs. optional "name" attribute

2001-04-22 Thread Craig R. McClanahan



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  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





Re: Required vs. optional "name" attribute

2001-04-23 Thread James Howe

At 10:00 PM 4/22/2001 -0700, you wrote:


>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.  [...]
>
>The HTML-oriented tags that allow you to default the "name" attribute can
>*only* be used within an  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


I understand your point.  How about if there were a new tag in Struts 
called "defaultName" (or something similar).  In the defaultName tag, you 
could identify a bean which automatically be referred to by all other tags 
unless a different bean name attribute were specified on a tag.  This would 
let you include common code and the common code wouldn't have to know the 
name of the bean from which it got its value unless it wanted to.


James W. Howe   mailto:[EMAIL PROTECTED]
Allen Creek Software, Inc.  pgpkey: http://ic.net/~jwh/pgpkey.html
Ann Arbor, MI 48103




Re: Required vs. optional "name" attribute

2001-04-23 Thread Jonathan Asbell

Incidentally, can antone tell me the difference between id, name, and
property?  (org.apache.struts.taglib.bean)


- Original Message -
From: "James Howe" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 23, 2001 12:01 PM
Subject: Re: Required vs. optional "name" attribute


> At 10:00 PM 4/22/2001 -0700, you wrote:
>
>
> >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.  [...]
> >
> >The HTML-oriented tags that allow you to default the "name" attribute can
> >*only* be used within an  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
>
>
> I understand your point.  How about if there were a new tag in Struts
> called "defaultName" (or something similar).  In the defaultName tag, you
> could identify a bean which automatically be referred to by all other tags
> unless a different bean name attribute were specified on a tag.  This
would
> let you include common code and the common code wouldn't have to know the
> name of the bean from which it got its value unless it wanted to.
>
>
> James W. Howe   mailto:[EMAIL PROTECTED]
> Allen Creek Software, Inc.  pgpkey:
http://ic.net/~jwh/pgpkey.html
> Ann Arbor, MI 48103
>