Hello Reid, Your question is of many folds.
check for "===>" for my sugestions below. Hope it helps you. --Shashi. ----- Original Message ----- From: "Reid Pinchback" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, December 14, 2001 9:12 AM Subject: Newbie question about caching data for forms > > Hi all, > > I've been reading through a lot of the Struts info available on > the web in various places, and I have a question I'm hoping > one of you more experienced folks can answer. There is > something simple that I think I'm still not getting. > > How, using the tag libraries of Struts, can I do the following: > > 1. If this is the first time that a user has visited the page, then > the form isn't pre-populated with any values. The user just > types in his/her desired form field values and hits submit. > > 2. If the webapp knows what the values should be, then the > form is first pre-populated with data for the user to edit > (e.g. if the user was on that page before but validation > failed, so all the fields are pre-populated with the user's > previously-submitted data). ===> For the above question: I have some thing very similar. I have a registration form which is generalized for both Registering a new user as well as Editing the profile of the existing user. I'm having a "session" variable that will be set to "ADD" when the user clicks on the "Register" link and is set to "MOD" when the user clicks on the "Edit Profile" link. The session variable will be set like follows: 1. In case of "ADD" invoke an Action Class to set the session variable and then forward to the registration form. 2. In case of "MOD" invoke another Action Class to get the data from the database set the FormBean and also the session variable. ===> You can set the value for the variables using the formbean in the JSP. It wouldn't create problems if the value is null. ===> The formbean has to have session scope. Specified in the struts-config.xml. > I think that somehow the html:form and/or bean:parameter > tags are where I need to look. To make this more concrete, > think of your standard login page. When the user first hits > the app, they type in their username and password on some > login.jsp page. If they screw up their password, they'll get > sent back to the login.jsp page, but now to be nice we'll > have the username field pre-populated. That was a simple > example; extend it to complex forms where there is a lot > of data to keep track of and multiple paths back to the form. > > In other words, what I'm looking for is the best (or at least > typical) idiom for using the struts tag libraries and associated > classes to capture the user data and bundle it not only for > processing by its action but to also hand that bundle back > to a JSP page if necessary. > > If somebody could show me a simple example of what the > JSP page and appropriate fragments of some associated form > and action class, I'd be muchly appreciative. I'd probably also > begin to feel a little more clueful than I do at the moment... > > Thanks! > > Reid > > > > > > --------------------------------- > Do You Yahoo!? > Check out Yahoo! Shopping and Yahoo! Auctionsfor all of your holiday gifts! -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

