You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthias Kerkhoff <ma...@BESToffers.de> on 2000/11/16 18:10:32 UTC

Need some help with struts-config.xml

Hi all,

I have some difficulties understanding the struts-config attributes
used to specify bean names/and classes. (See questions at the end of
this mail)

In struts-config there are:

- <form-bean name=... type=...> with

      name - Unique identifier of this bean, used to reference it
             in corresponding action mappings.
        
      type - Fully qualified Java class name of the implementation
             class to be used or generated

- <action name=... attribute=... scope=... > with

      name - Name of the form bean, if any, that is associated
             with this action.

 attribute - Name of the request-scope or session-scope attribute
             under which our form bean is accessed, if it is other
             than the bean's specified "name".  Optional if
             name" is specified, else not allowed.
        
     scope - Identifier of the scope ("request" or "session") within
             which our form bean is accessed, if any.  Optional if
             name" is specified, else not allowed.

             
and then, there is the related form tag


- <form:form name=... type=... scope=...> with

      name - Name of the request scope or session scope bean (as defined by
             the scope attribute) whose properties will be used to populate
             input field values. If no such bean is found, a new bean will
             be created (and added to the appropriate scope), using the Java
             class name specified by the type attribute.

     scope - JSP scope within which the associated bean will be accessed
             or created (request, session).
             
      type - Fully qualified Java class name of the bean to be created
             if no bean is found for the specified name and scope. To
             be used successfully with the Struts ActionServlet, this class
             must implement the org.apache.struts.action.ActionForm interface.

             

Can someone please explain the relationships between these attributes,
especially ...

... is action.name a reference to form-bean.name ?

... if action.attribute is ommitted, will action.name then also be
    used as key under which the bean is searched/stored in the
    specified scope ?

... why has the form-tag the above mentioned attributes, if it could
    also fetch them from the <action...> mapping in struts-config.xml,
    using the <form:form action=..> as a key to lookup the appropriate
    action (mapping) ? Or, asking it the other way, would it make
    sense to default the form attributes - if not present - to their
    counterparts from action and form-bean ?

... why are different defaults used for action.scope (request) and
    form.scope (session) ?


Thanks in advance!
Matthias                          mailto:make@BESToffers.de