Peter Valencic wrote:
Hello to all...
I'am working on a large project for car assicuration.
My question is if it's possible to prepopulate a form for example..
On page A user must enter policy number... then in actionForm bean i get
datas from DB and depends on datas I must prepopulate a form B
Anyone have some short example how to prepopulate a ActionForm..?
I tryed to get actionForm bean from session but I'dont know if this is
ok...
for example this code is from my ActionForm which is on page A:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
System.out.println("================");
System.out.println("Action1");
session = request.getSession();
AO2formbean fmb = (AO3formbean)
session.getAttribute("AO2formbean"); <--- this is a bean (ActionForm
which is on page B)
fmb.setName("ccccc"); <-- here I set some data (prepopulate
actionform bean from page B)
session.setAttrribute("AO2formbean",fmb); <-- here I'store a
bean in session...
return mapping.findForward("ok");
}
Is this correct or no?
Hmm. How do you get AO2formbean into the session in the first place?
More to the point, why are you trying to initialize the data for form B
in the action for form A?
I need 2 things
first i must strore a bean in session because I must display some data
from bean many times on different forms (pages)..
second i must prepopulate fields displayed in next page (A -> B)
I think you probably want to do a couple of things to meet this requirement:
1) for all the forms that need to share data, configure them to use the
same session-scoped form
2) whenever a form requires data to be pre-populated, make sure you have
an action to handle that; when you want to display that form, do so by
calling (forwarding/redirecting to) the action that knows how to prepare it
If that doesn't make sense, try posting a more complete example of what
you're trying to do, including form-bean and action mappings from your
config file as well as appropriate snippets of your action code.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]