• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Prepoulating form fields

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know I've seen this discussed previously, but I'm not having any luck searching the forum.

I'm trying to prepopulate some form fields from user information that is held in the session (things like name, email address etc).

I have a link that goes to a "setup action" where I check to see if a user is logged in, if they are I use myForm.setXX(user.getXX). Return mapping.findForward("continue") (which goes to the page that actually displays the form). Both actions in the config file have the same value for the name attribute. However the form is not showing any values (checking session variables, I know the user values are there.. just the form doesnt seem to be getting set).

-Tad
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post what you have so far please.
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah ok, I figured out my problem the html:form name attribute needs to be the same name as the form attribute name in the struts config file duh.

-Tad
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jsp:

Setup action:
Struts-config



I'm baffeled... when I changed the form name from dataCorrection to DataCorrection it started working, despite the fact its different from whats in the config file. Although I just noticed in the setupaction I put the form in the request, under yet a different name than whats in the config file, maybe this is what has me confused.
[ December 16, 2004: Message edited by: Tad Dicks ]
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I'm at a loss why changing the name of the form from dataCorrection to DataCorrection causes it to work. Regardless of the name of the form in the struts-config is "dataCorrection" or "DataCorrection", or wether or not I load the form into the request "manually" inside the setup action. I don't think I can find any other place I refer to or name this form.

Should the name of the form inside the <html:form> tag (in the JSP) be the same as the name of the formbean as declared inside the struts-config file?


-Tad
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok it was working... I had no idea how/why. Now its not working again no idea why it stopped, truly frustrating. I've tried changing so manythings.



the bean write at the bottom for property firstName writes out the correct value its stored there. Its just not being displayed in the form.

I followed the directions from the apache site the best I could. I have a seupt action and I set the values inside of that action and then do a forward to the above page.

-Tad
[ December 16, 2004: Message edited by: Tad Dicks ]
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I know I'm mostly rambling to myself here, but
changing:

<html:form name="dataCorrection" action="DataCorrectionSub" type="com.formBeans.DataCorrectionForm" focus="firstName">

to

<html:form action="DataCorrectionSub" focus="firstName">
fixed the problem?
does giving the form a name and type cause the page to create an new instance of the formBean class? How does teh form know what bean to associate to it?(through the action?).
reply
    Bookmark Topic Watch Topic
  • New Topic