Dear Struts Users,
We are having a problem with Struts 0.5. We realize that 0.5 is very
old code, but because of our client we cannot upgrade to a more stable
version.
The problem we are having is like this: We have an application
whose front-end is JSPs. For each JSP, we have what we call a "startAction"
and an Action. So that the program flow looks something like this:
startActionOne => One.jsp => ActionOne => startActionTwo => Two.jsp =>
ActionTwo => startActionThree => etc.....
so that each Action forwards to the startAction of the next screen.
We also have a form object that we use for the entire application
flow. This form is in the session scope. We have certain variables that we
set by hand in the form object from within the Action classes. However, in
one place in our application, the JSP actually sets one of the form
attributes/member-variables and the Action class reads that variable. From
there, the Action class sets the variable to a new value. The problem seems
to be that between the Action setting the variable, and the next
startAction, the variable gets reset to the value it was at the end of the
JSP.
The following pseudocode may help to explain what we do:
This is the JSP that we start from. The startAction to get to this
JSP only returns an actionForward to this One.jsp; there is not setup
required before loading this very simple page.
One.jsp *************************************
<script language="JavaScript">
function selectAction(val) {
roleForm.formAction.value = val;
}
</script>
<struts:form action="One.do" name="roleForm" scope="session"
type="com.insystems.RoleForm">
<input type="image" name="addRole" src="add.jpg"
onClick="selectAction('Jane')">
</form>
end One.jsp *************************************
The page submits and the action.xml forwards to OneAction, From
here, we would like to read the value of the formAction variable in our
RoleForm class. We print out the value to see what it is before moving on.
OneAction.java *************************************
protected ActionForward onPerform(ActionParameters actionParameters)
{
System.out.println("*********** OneAction
**************START");
RoleForm roleForm = (RoleForm) actionParameters.form();
roleForm.setFormAction("Bob");
System.out.println("*********** OneAction
**************END");
return actionParameters.forward("startTwo");
}
end OneAction.java *************************************
As you can see, we override the value of "Jane" for the formAction
attribute with the value of "Bob". What we find is that when we reach
startTwoAction, the value of the formAction attribute is reset back to
"Jane" -- even though we forced it to be Bob. The forward to "startTwo"
actually forwards to "startTwoAction" (as I described earlier in the program
flow above).
startTwoAction.java *************************************
protected ActionForward onPerform(ActionParameters actionParameters)
{
System.out.println("*********** startTwoAction
**************START");
RoleForm roleForm = (RoleForm) actionParameters.form();
roleForm.getFormAction(); // Do nothing with the value,
for testing purposes.
System.out.println("*********** startTwoAction
**************END");
return actionParameters.forward("Two");
}
end startTwoAction.java *************************************
This startAction is just as simple as startOneAction; it does
nothing but forward to the JSP.
Now let's get to the meat of the problem. The value of formAction
gets RESET after the end of OneAction and before the start of
startTwoAction. Since there is no code of ours that get executed in between,
this seems to make no sense. We added debug print statements to our form
class in order to show all set and get calls, and this is the output that we
get:
------------------ program output ------------------
RoleForm : setFormAction() value = Jane
*********** OneAction **************START
RoleForm : setFormAction() value = Bob
*********** OneAction **************END
RoleForm : setFormAction() value = Jane
*********** startTwoAction **************START
RoleForm : getFormAction() value = Jane
*********** startTwoAction **************END
------------------ end program output ------------------
The first line is the set call made in the JSP through JavaScript.
The line in red seems to be our problem. We would like to know who
makes this set call? And how can we get rid of it? We do not really expect
any code to be making get/set calls to our form between Action calls --
especially when we are forwarding from one Action to another without any
JSPs in between.
We would greatly appreciate any help anybody can offer with this
problem. Thanks.
Sincerely,
Daryl and Terry.
P.S. We are using Struts 0.5 with Tomcat 3.2 on Windows2000.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>