You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ross <te...@yahoo.com> on 2001/04/30 20:49:31 UTC

Form tag question

Hi all

I'm working my way through struts-example and the documentation and I
am confused about the process a form tag takes to create an ActionForm
bean if one doesn't exist. There seems to be conflicting documentation.

The walking tour of the example says.

>First, the logon.jsp makes use of the custom-tag "form". This tag can
>scan the application's properties for a form bean related to the
>path /logon.jsp (from the link on the welcome page).

Which sounds the same as the html tag libray guide which says:

>The name of the bean and its class can be specified as a property to
>the form tag, but may also be omitted. If omitted, the ActionMappings
>database (loaded from the struts-config.xml file) is consulted. If the
>current page is specified as the input property for an action, the
name
>of the action is used. The type property for the bean is also then
>taken from the configuration, via a Form Bean definition.

But the html tag library reference says this for the name attribute of
the form tag:

>Name of the request scope or session scope bean (as defined by the
>scope attribute) whose properties will be used to populate the 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.
>
>If this attribute is not specified, it will be calculated by using the
>value of the action attribute to look up the corresponding
>ActionMapping element, from which we will select the specified form
>bean name.

So in struts-example/login.jsp, does it find a correct action mapping
because there is a mapping with path="/logon" which is the same as the
form tag action attribute or does it find it because input="/logon.jsp"
which is the jsp url?

If the ActionForm bean is created in a form tag rather than in an
action bean earlier, do the request parameters not get updated to the
bean? I notice that if I go directly to login.jsp and append
?username=ross to the url, then this does not appear in the textbox.

Slightly off topic but do I understand correctly that the reason why
the login link in struts-example/index.jsp goes directly to login.jsp
rather than login.do is because in the case of a login form we don't
want to display anything initially in the boxes. That is the main thing
that's different between login and other forms in the example. Usually
we would go to an action instead of a jsp directly?

Thanks
Ross


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/