Believe it or not, Sri, your questions were incredibly helpful! Comments
in-line ...
On 03/19/2003 11:21:40 AM Sri Sankaran wrote:
What do you mean by does not seem to work? Do you get null values?
NPE?
Yes, that was a bit vague. Sorry about that. Regarding the html:hidden
values, I was using the 'property' tag attribute without specifying a
'name' attribute, so I was just getting blank values.
Is your ActionFormA still in scope (available) in SetupActionB? In
other
words, can you get a non-null value for either of
request.getAttribute(ActionFormA.key);
Always using request scope ... trying this in SetupActionB does in fact
give me a null. But, actually, I should expect that, right? If
SetupActionA uses FormA, then displays the A.jsp ... that expires the
request object. Which should mean that the following from the SetupActionA
request.setAttribute(mapping.getAttribute(), myFormA);
is also expired, so as an attribute FormA is no longer available once
A.jsp is displayed.
On A.jsp the submit button action calls SetupActionB, which uses FormB. So
submitting the html form begins a new request, but then FormB is now
loaded into request scope. Correct?
So the mystery turned into ... what happens to the submitted parameters? I
think I have this right now, in saying that the parameters values,
originally supplied by FormA, get copied into the matching fields on the
new FormB. It doesn't matter that you are using two different ActionForms
on either side of the jsp page, but the fields you wish to continue to use
in SetupFormB must be present in FormB. Naturally, if you are using the
same ActionForm before and after the display page, it works without having
to think about it.
Elementary Struts, as I said previously, and probably already obvious to
most others!
or
session.getAttribute(ActionFormA.key);
Sri
Thank you for the help.
Susan Bradeen
-Original Message-
From: Susan Bradeen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 3:23 PM
To: [EMAIL PROTECTED]
Subject: Using different actionform types before and after a display
page.
I normally use the same *type* of action form before and after my jsp
pages, but what if the jsp submits to an action that uses a different
type
of action form, but contains a few of the same fields that I'd like to
use
in that second action? Can I retrieve the submitted values (coming from
one action form type) to use in an action with a different action form
type?
Too confusing? :-)
If I have ...
SetupActionA, using its ActionformA, to display A.jsp
and ...
SetupActionB, using its ActionformB, to display B.jsp
Now say that my A.jsp contains a form that submits to SetupActionB.
If the ActionformA and the ActionformB contain a few identical fields,
is
it correct that the parameters submitted from A.jsp can be retrieved and
used by my ActionformB in the SetupActionB?
public class SetupActionA extends Action {
public ActionForward execute(...) throws Exception {
ActionformA formA = (ActionformA) form;
formA.setMyID(someID);
formA.setMyName(someName);
... etc
}
}
public class SetupActionB extends Action {
public ActionForward execute(...) throws Exception {
ActionformB formB = (ActionformB) form;
formB.setMyID(*** get this from the A.jsp parameters ***);
formA.setMyName(*** get this from the A.jsp parameters ***);
... etc
}
}
My tests so far have been unsuccessful, especially for html:hidden
field
values. I know that I can use request.getParameter(myID), for values
submitted by the html form, but this does not seem to work for
html:hidden fields.
I think I am getting tripped up by an elementary Struts concept
(ActionForm instances?), but my brain seems to be up against a brick
wall
at the moment.
Thanks for any clarification.
Susan Bradeen
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]