You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by David Geary <sa...@tri-lakesonline.net> on 2000/06/18 00:32:23 UTC

ActionForward Path Does Not Retain Form Values

I've got an application with a minimal form, that looks like this:

[Image]

The text fields and submit button are <struts:text> and <struts:submit>,
respectively. The text
below the submit button is generated like this:

<struts:form action='exampleAction.do' name='thisForm' method='get'
       type='com.company.forms.ExampleForm' >
...
<% ExampleForm form =
  (ExampleForm)pageContext.findAttribute("thisForm"); %>

<%= "Form: " + form.hashCode() %>,
<i>name: <%= form.getName() %>
<i>address: <%= form.getAddress() %>

The form's action is exampleAction.do, and its type is
com.company.forms.ExampleForm.
ExampleForm.perform() returns new ActionForward("/example.jsp"). So,
when the submit
button above is activated, control is forwarded to example.jsp, which
looks like this:

[Image]

Here's the code for example.jsp:

Example JSP File: This is the path specified for an ActionForward
      by com.company.actions.ExampleAction.

<%@ page import='com.company.forms.*' %>

<% ExampleForm form =
(ExampleForm)pageContext.findAttribute("thisForm"); %>

<p><%= form.hashCode() %>,
<i>name: <%= form.getName() %>
<i>address: <%= form.getAddress() %></p>

Re: ActionForward Path Does Not Retain Form Values

Posted by David Geary <sa...@tri-lakesonline.net>.
I figured it out, sorry to bother everyone. I was using the wrong form
attribute.
david


Re: ActionForward Path Does Not Retain Form Values

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
A zip file would be really helpful to isolate what the issues are.

Craig


David Geary wrote:

> I've got an application with a minimal form, that looks like this:
>
> [Image]
>
> The text fields and submit button are <struts:text> and
> <struts:submit>, respectively. The text
> below the submit button is generated like this:
>
> <struts:form action='exampleAction.do' name='thisForm' method='get'
>        type='com.company.forms.ExampleForm' >
> ...
> <% ExampleForm form =
>   (ExampleForm)pageContext.findAttribute("thisForm"); %>
>
> <%= "Form: " + form.hashCode() %>,
> <i>name: <%= form.getName() %>
> <i>address: <%= form.getAddress() %>
>
> The form's action is exampleAction.do, and its type is
> com.company.forms.ExampleForm.
> ExampleForm.perform() returns new ActionForward("/example.jsp"). So,
> when the submit
> button above is activated, control is forwarded to example.jsp, which
> looks like this:
>
> [Image]
>
> Here's the code for example.jsp:
>
> Example JSP File: This is the path specified for an ActionForward
>       by com.company.actions.ExampleAction.
>
> <%@ page import='com.company.forms.*' %>
>
> <% ExampleForm form =
> (ExampleForm)pageContext.findAttribute("thisForm"); %>
>
> <p><%= form.hashCode() %>,
> <i>name: <%= form.getName() %>
> <i>address: <%= form.getAddress() %></p>
>
> From the hash code it's evident that I'm accessing the same
> ExampleForm object, however the
> form's values arenull by the time the forwarding occurs. (they should
> be null initially, because
> the form has not been processed)
>
> Any ideas? I'd be happy to supply a ZIP file of the source.
>
>
> david
>
>
>

Re: ActionForward Path Does Not Retain Form Values

Posted by David Geary <sa...@tri-lakesonline.net>.
I figured it out, sorry to bother everyone. I was using the wrong form
attribute for accessing the form.


david