Vanishing parameters
I have a struts application with an intermittent problem of losing all it's parameters from the request. Is there any known problem, mis-coding, or whatever that would cause that? The application has a set of jsp pages each with one or more buttons for submit, cancel, and other actions. The JSPs have unremarkable forms with some text and textArea inputs, a few 'hidden' types, etc. All of these get put into the request upon hitting submit and processing the action. On the page in question most submits process normally but one out of every 5 (or fewer) times the submit doesn't happens but the various parameters of the request don't reach the struts Action.execute(). To add to my puzzlement, this page uses standard (I hope) struts validation. This has been tested and without the required inputs validation blocks processing in the way that it should. When I look at my logs, I read out the parameters as the very first thing in the execute() method. At that point the parameters are missing for that one in five (or whatever) intermittent problem. So it seems that somewhere after validation but before reaching the execute of my action the parameters are being lost. Another point to make is that my requests have a session object with contents and a few other attributes. None of those attributes are being lost - just the parameters. Any ideas on what could be causing this or suggestions about how to investigate it?
Security and information passing
What are the options within Struts (version 1) for passing information from one request to the next on a multi-page struts application? I can pass some information as request parameters and hidden inputs on forms but that's not acceptable for credit card numbers, passwords, etc. What are the other options and how do they work? How, if at all, do people manage a single sign on to pages when a user needs to sign in. If there are some URLs with discussion on the topics, let me know.
Parameterizing the struts-config file
Can I use a parameter instead of a hard coded value in the mappings of a struts-config.xml? If so, how? What I mean is: I have a config file that looks like so: action path=/myAction type=com.softrek.conference.MyAction name= myForm scope=request validate=false forward name=winMoney redirect=true path=winner.jsp / forward name=loser path=thankYou.jsp / /action This requires an Action that has exactly 'winMoney' and 'loser' as the strings in the mapping.findForward(). Can I use some sort of ForwardNames.WIN_MONEY instead? Or any other parameter that will keep the strings identical. Ideally with only one place to modify the string if it changes. Is this possible? How?
Re: Service unavailable error
Don's reply? Your's is the only reply to make it to me. Can you send me a copy of this other reply? I will see about changing my DOCTYPE line. On 1/31/07, Simons Kevin [EMAIL PROTECTED] wrote: On top of Don's reply I once had done the same mistake. I thought they told me that your version !DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.3.5//EN needs to be the same as stated here http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd; so I think that struts-config_1_1.dtd http://jakarta.apache.org/struts/dtds/struts-config-1.3.5.dtd; Regards, - Original Message - From: Thom Burnett [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, January 31, 2007 6:44 PM Subject: Service unavailable error When I deploy and go to my struts application I get the following error: Does the error indicate an error in my struts-config.xml file or in some file referenced by the struts-config.xml file? I'm trying to figure out how to hunt down and kill this error. - 503 Service Unavailable Servlet error: Parsing error processing resource path file:/usr/oracle/OraHome_1/j2ee/OC4J_tburnett/applications/conference/cwapp-conference/WEB-INF/struts- config.xml -- My struts-config.xml: I commented out large chunks of it trying to locate a problem. Doesn't seem to matter. With none of the comments I get the same error message. ?xml version = '1.0' encoding = 'windows-1252'? !DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.3.5//EN http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd; struts-config form-beans form-bean name=loginForm type=com.softrek.conference.LoginForm / !-- form-bean name=registrationForm type=com.softrek.conference.RegistrationForm / form-bean name=creditCardForm type= com.softrek.conference.CreditCardForm / -- /form-beans !-- global-exceptions exception key=global.exception path=/error.jsp scope=request type=java.lang.Throwable / /global-exceptions -- action-mappings action path=/login type=com.softrek.conference.LoginAction name=loginForm scope=request validate=true forward name=login path=/login.jsp / forward name=softrek redirect=true path=http://www.softrek.com; / /action !-- action path=/eventSetup type=com.softrek.conference.EventSetupAction name=registrationForm scope=request validate=true forward name=eventSelection path=/eventSelectionPage.jsp / forward name=softrek redirect=true path=http://www.softrek.com; / forward name=login path=/login.jsp / /action action path=/eventSelection type=com.softrek.conference.EventSelectionAction name=registrationForm scope=request validate=true forward name=guestEntry path=/guestEntryPage.jsp/ forward name=login path=/login.jsp/ /action action path=/guestEntry type=com.softrek.conference.GuestSelectionAction name=registrationForm scope=request validate=true forward name=payment path=/paymentPagePage.jsp/ /action action path=/payment type= com.softrek.conference.PaymentAction name=creditCardForm scope=request validate=true forward name=accepted path=/thankYouPage.jsp/ forward name=denied path=/deniedPage.jsp/ /action -- /action-mappings !-- message-resources parameter=ApplicationResources null=false / plug-in className=org.apache.struts.validator.ValidatorPlugIn set-property property=pathnames value=/WEB-INF/validator/validator-rules.xml,/WEB-INF/validator/validation.xml/ /plug-in -- /struts-config No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.14/658 - Release Date: 29/01/2007 14:49 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Service unavailable error
When I deploy and go to my struts application I get the following error: Does the error indicate an error in my struts-config.xml file or in some file referenced by the struts-config.xml file? I'm trying to figure out how to hunt down and kill this error. - 503 Service Unavailable Servlet error: Parsing error processing resource path file:/usr/oracle/OraHome_1/j2ee/OC4J_tburnett/applications/conference/cwapp-conference/WEB-INF/struts-config.xml -- My struts-config.xml: I commented out large chunks of it trying to locate a problem. Doesn't seem to matter. With none of the comments I get the same error message. ?xml version = '1.0' encoding = 'windows-1252'? !DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.3.5//EN http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd; struts-config form-beans form-bean name=loginForm type=com.softrek.conference.LoginForm / !-- form-bean name=registrationForm type=com.softrek.conference.RegistrationForm / form-bean name=creditCardForm type=com.softrek.conference.CreditCardForm / -- /form-beans !-- global-exceptions exception key=global.exception path=/error.jsp scope=request type=java.lang.Throwable / /global-exceptions -- action-mappings action path=/login type=com.softrek.conference.LoginAction name=loginForm scope=request validate=true forward name=login path=/login.jsp / forward name=softrek redirect=true path=http://www.softrek.com; / /action !-- action path=/eventSetup type=com.softrek.conference.EventSetupAction name=registrationForm scope=request validate=true forward name=eventSelection path=/eventSelectionPage.jsp / forward name=softrek redirect=true path=http://www.softrek.com; / forward name=login path=/login.jsp / /action action path=/eventSelection type=com.softrek.conference.EventSelectionAction name=registrationForm scope=request validate=true forward name=guestEntry path=/guestEntryPage.jsp/ forward name=login path=/login.jsp/ /action action path=/guestEntry type=com.softrek.conference.GuestSelectionAction name=registrationForm scope=request validate=true forward name=payment path=/paymentPagePage.jsp/ /action action path=/payment type=com.softrek.conference.PaymentAction name=creditCardForm scope=request validate=true forward name=accepted path=/thankYouPage.jsp/ forward name=denied path=/deniedPage.jsp/ /action -- /action-mappings !-- message-resources parameter=ApplicationResources null=false / plug-in className=org.apache.struts.validator.ValidatorPlugIn set-property property=pathnames value=/WEB-INF/validator/validator-rules.xml,/WEB-INF/validator/validation.xml/ /plug-in -- /struts-config
Design within struts
What is the general approach in creating action classes for Struts. At the moment, any given project that I work on seems to have pretty close to one new Action class for each page. If the page is at all complicated, has it's own form or data, it seems to need a separate Action.execute(). In fact, if there's more than one button on the page, sometimes it makes sense to have more than one Action for that page. The result is a lot of classes extending from Action. Now I could, with difficulty, make a single Action class and then within the execute method sort according to what page and form accompany the request. My question is, what's the recommended practice. Is it considered best to keep different actions for each major purpose or to have one Action (controller) sorting and dispatching incoming requests.
Session ending
What's the standard definition of the end of a session. That is, if there's no session.invalidate() call, how should servlets (esp the struts servlet) decide that a request is part of a new session? Where is this discussed - some tutorial or documentation on the web? I have a struts application where the request.session object seems to be ending between actions. That is one action forwards to another action and when the request eaches the 2nd action the session no longer contains what it clearly had in the first session. This has only happened with IE 7. It doesn't happen when Firefox is used and doesn't seem to happen with older versions of IE tho I'm not completely sure of that. Any thoughts?
Validation rule writing
I'm trying to validate two fields - area code and phone number (as nnn- no areacode in that input). Various samples and reading suggest that I should be able to create a mask and apply it as below but my result is that the area code can't be empty but it can contain letters, be longer than 3. It's ignoring my regular expression mask. Am I missing something simple in how to setup and use the validations.xml or am I going about this in the wrong way? ?xml version='1.0' encoding='windows-1252'? form-validation global constant constant-namephoneFormatMask/constant-name constant-value^[0-9]{3}-[0-9]{4}$/constant-value /constant constant constant-nameareaCodeFormatMask/constant-name constant-value^[0-9]{3}$/constant-value /constant /global formset !-- Start of validation rules for each bean -- form name=contactBean field property=firstName depends=required page=1 arg0 key=validation.error.firstname/ /field field property=lastName depends=required page=1 arg0 key=validation.error.last/ /field field property=email depends=required, email page=1 arg0 key=validation.error.email/ /field field property=areaCode depends=required, areaCodeMask page=1 arg0 key=validation.error.areaCode/ msg name=areaCodeMask key=validation.error.areaCode.format/ var var-nameareaCodeMask/var-name var-value${areaCodeFormatMask}/var-value /var /field field property=phoneNumber depends=required, phoneMask page=1 arg0 key=validation.error.phone/ var var-namephoneMask/var-name var-value${phoneFormatMask}/var-value /var /field ... /form /formset /form-validation
Multiple buttons and validation
I have a few buttons on my jsp page and I want to have validation happen on some buttons and not on other buttons. Is that possible? How? Any examples around?
The first request
I need to set up my first page with a sequence of database interactions before the execute() method is called (I think). What's the recommended struts way of doing so. When a first request to my jsp page arrives, I need to read some key parameters of the request, contact my database, and then fill in some fields of the page based on what the parameters and database tell me. I'm not clear on how to hook that in. I don't seem to have access to the doPost() and doGet() methods that I would with a standard servlet. 1. One obvious solution is to extend the struts ActionServlet so that I can override the doGet() and/or doPost(). Does that interfere with standard struts behavior? 2. I could also use a standard servlet to handle the request and then forward or redirect to my struts pages and servlet. That seems to somewhat defeat the purpose of struts but it could be done. 3. I could also put a lot of java into my jsp page to do all my processing but that's a violation of MVC and pretty messy as well. 4. I thought about using the constructor of my ActionForm since it gets called at the right time but I don't have the request object available (and I need those parameters). 5. Any other ideas? I need a solution (preferably an example) that works for struts 1.3.5. with an ActionForm (not the DynaActionForm).
Re: Two values on input attribute
I tried this technique for my situation where several jsp pages contribute to one ActionForm. I'm getting the correct page selection behavior by my errors don't show up. For the first page (the donation page) everything works very nicely. For the second page (the honoree page) there's no trace of an error message. That is, when (and only when) there's an error, the page will not continue on to the next page but the html:errors/ tag seems to return no contents - that part of the displayed page is blank. I can't see any meaningful difference between the two pages. Is this a question of where the ActionErrors instance is stored? struts-config ... action path=/donation3 type=com.softrek.donation.DonationAction3 name=donorBean scope=session input=/donation3.jsp validate=true forward name=oracleError path=/oracleError3.jsp/ forward name=success path=/thankYou3.jsp/ forward name=firstPagepath=/donation3.jsp/ forward name=secondPage path=/honoree3.jsp/ forward name=thirdPagepath=/payment3.jsp/ /action action path=/honoree3 type=com.softrek.donation.DonationAction3 name=donorBean scope=session input=/honoree3.jsp validate=true forward name=oracleError path=/oracleError3.jsp/ forward name=success path=/thankYou3.jsp/ forward name=firstPagepath=/donation3.jsp/ forward name=secondPage path=/honoree3.jsp/ forward name=thirdPagepath=/payment3.jsp/ /action ... donation3.jsp page ... % AllDonationInformationFormBean3 donorBean = (AllDonationInformationFormBean3)session.getAttribute(donorBean) ; if(donorBean == null) donorBean = new AllDonationInformationFormBean3() ; % body center h1New Account Registration/h1 /center form action=../donation3/donation3.do method=post input type=hidden name=pagename value=donationPage/ input type=hidden name=page value=1/ p style=background-color:rgb(0,255,255); font-size:large;Donor Information/p html:errors/br/ p*Indicates required field/p ... honoree3.jsp page ... % AllDonationInformationFormBean3 donorBean = (AllDonationInformationFormBean3)session.getAttribute(donorBean) ; if(donorBean == null) donorBean = new AllDonationInformationFormBean3() ; % html head meta http-equiv=Content-Type content=text/html; charset=windows-1252 titleHonor of/title /head body center h1In Honor Of/h1 /center form action=../donation3/honoree3.do method=post input type=hidden name=pagename value=honoreePage/ input type=hidden name=page value=2/ P style=background-color:rgb(0,255,255); font-size:large;In Honor of:/P P*Indicates required field/P html:errors/br/ ... On 11/4/06, Christopher Schultz [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yariel, I have a page validated with Validation Framework, but I can get that page from two diferent jsp inputs. When an error ocurs, the validator always turn me back to the same jsp input (the one especified) not matter which was the selected input. It is possible to set two values to input attribute in an ActionMapping?? Is there any other way to do something like that?? Generally, this is done with two separate ActionMappings, like this: !-- submit to here from first.jsp -- action path=/path1 type=MyAction name=MyFormBean validate=true scope=request input=/first.jsp ... /action !-- submit to here from second.jsp -- action path=/path2 type=MyAction name=MyFormBean validate=true scope=request input=/second.jsp ... /action You are doing the exact same thing in both cases, except that the input attributes are different. The validation should be the same, using the same form bean, etc. Hope that helps, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFTJOE9CaO5/Lv0PARArvPAJ9/6S//E9jkQFVy/QC2mIGUTMBgAACgr4d2 NY36tWCeaj9w/2bBwcBpKKY= =CJAz -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two values on input attribute
First, I found my error and it's (of course) not in any of the code listed. I had neglected the import statements in the jsp pages. :-( So you can ignore this question but it does bring up another one. Is there a way to get warnings or error messages when I've made a mistake like this in the jsp? In my build there was no compiler error or warning. Finding this type of error by inspection is very time consuming. On 11/8/06, Thom Burnett [EMAIL PROTECTED] wrote: I tried this technique for my situation where several jsp pages contribute to one ActionForm. I'm getting the correct page selection behavior by my errors don't show up. For the first page (the donation page) everything works very nicely. For the second page (the honoree page) there's no trace of an error message. That is, when (and only when) there's an error, the page will not continue on to the next page but the html:errors/ tag seems to return no contents - that part of the displayed page is blank. I can't see any meaningful difference between the two pages. Is this a question of where the ActionErrors instance is stored? struts-config ... action path=/donation3 type= com.softrek.donation.DonationAction3 name=donorBean scope=session input=/donation3.jsp validate=true forward name=oracleError path=/oracleError3.jsp/ forward name=success path=/thankYou3.jsp/ forward name=firstPagepath=/donation3.jsp/ forward name=secondPage path=/honoree3.jsp/ forward name=thirdPagepath=/payment3.jsp/ /action action path=/honoree3 type=com.softrek.donation.DonationAction3 name=donorBean scope=session input=/honoree3.jsp validate=true forward name=oracleError path=/oracleError3.jsp/ forward name=success path=/thankYou3.jsp/ forward name=firstPagepath=/donation3.jsp/ forward name=secondPage path=/honoree3.jsp/ forward name=thirdPagepath=/payment3.jsp/ /action ... donation3.jsp page ... % AllDonationInformationFormBean3 donorBean = (AllDonationInformationFormBean3)session.getAttribute(donorBean) ; if(donorBean == null) donorBean = new AllDonationInformationFormBean3() ; % body center h1New Account Registration/h1 /center form action=../donation3/donation3.do method=post input type=hidden name=pagename value=donationPage/ input type=hidden name=page value=1/ p style=background-color:rgb(0,255,255); font-size:large;Donor Information/p html:errors/br/ p*Indicates required field/p ... honoree3.jsp page ... % AllDonationInformationFormBean3 donorBean = (AllDonationInformationFormBean3)session.getAttribute(donorBean) ; if(donorBean == null) donorBean = new AllDonationInformationFormBean3() ; % html head meta http-equiv=Content-Type content=text/html; charset=windows-1252 titleHonor of/title /head body center h1In Honor Of/h1 /center form action=../donation3/honoree3.do method=post input type=hidden name=pagename value=honoreePage/ input type=hidden name=page value=2/ P style=background-color:rgb(0,255,255); font-size:large;In Honor of:/P P*Indicates required field/P html:errors/br/ ... On 11/4/06, Christopher Schultz [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yariel, I have a page validated with Validation Framework, but I can get that page from two diferent jsp inputs. When an error ocurs, the validator always turn me back to the same jsp input (the one especified) not matter which was the selected input. It is possible to set two values to input attribute in an ActionMapping?? Is there any other way to do something like that?? Generally, this is done with two separate ActionMappings, like this: !-- submit to here from first.jsp -- action path=/path1 type=MyAction name=MyFormBean validate=true scope=request input=/first.jsp ... /action !-- submit to here from second.jsp -- action path=/path2 type=MyAction name=MyFormBean validate=true scope=request input=/second.jsp ... /action You are doing the exact same thing in both cases, except that the input attributes are different. The validation should be the same, using the same form bean, etc. Hope that helps, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFTJOE9CaO5/Lv0PARArvPAJ9/6S//E9jkQFVy/QC2mIGUTMBgAACgr4d2 NY36tWCeaj9w/2bBwcBpKKY= =CJAz -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Starting validation
What are common simple mistakes that would prevent validation from occuring? I've got a simple struts application that runs correctly except that validation doesn't occur. The form info is accepted as correct when required information is missing. I'm trying to figure out what's missing from my setup or understanding. The ValidatorForm (my extension) class has appropriate get and set functions for all fields. (The fields are spread over 3 jsp pages, if that matters.) I've added the validator plugin to the struts-config, the action mapping has validate=true and a valid input path, added the validation-rules and validation.xml file, added the resource properties file with the standard errors (taken from the struts file). If I write my own validate method in the form bean that validation works properly. It's my understanding that if I'm using the validation framework, I should not have a validate() method in the form. Am I misunderstanding something? Any ideas what might be setup wrong or missing.
Re: Starting validation
What's now happening is that the validation correctly moves me back to the jsp specified by input but the form becomes blank (doesn't keep the information that was entered) and the html:errors returns nothing. I can sort of get around this by calling validate and adding attributes to the request but I'm pretty sure that I shouldn't need to do so. So I'm wondering what's going wrong. struts-config.xml: ?xml version = '1.0' encoding = 'windows-1252'? !DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.3.5//EN http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd; struts-config form-beans form-bean name=donorBean type= com.softrek.donation.AllDonationInformationFormBean3/ /form-beans action-mappings action path=/donation3 type=com.softrek.donation.DonationAction3 name=donorBean scope=session input=/donation3.jsp validate=true forward name=error path=/error3.jsp/ forward name=success path=/thankYou3.jsp/ forward name=firstPagepath=/donation3.jsp/ forward name=secondPage path=/honoree3.jsp/ forward name=thirdPagepath=/payment3.jsp/ /action /action-mappings message-resources parameter=/WEB-INF/ErrorMessages/ plug-in className=org.apache.struts.validator.ValidatorPlugIn set-property property=pathnames value=/WEB-INF/validator/validator-rules.xml ,/WEB-INF/validator/validations.xml/ /plug-in /struts-config public class AllDonationInformationFormBean3 extends ValidatorForm { ... // This is the addition I seem to need. public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors actionErrors = super.validate(mapping, request) ; request.setAttribute(sessionForm, this) ; // If I don't do this the form will be blank after an error. request.setAttribute(errors, actionErrors) ; return actionErrors ; } } My validations.xml file - working partially ?xml version='1.0' encoding='windows-1252'? form-validation formset !-- Start of validation rules for each bean -- form name=donorBean field property=firstname depends=required arg0 key=validation.error.firstname/ /field field property=zip depends=required arg0 key=validation.error.zip/ /field field property=last depends=required page=1 arg0 key=validation.error.last/ /field field property=line1 depends=required page=1 arg0 key=validation.error.line1/ /field field property=email depends=email page=1 arg0 key=validation.error.email/ /field field property=t_amount depends=required page=1 arg0 key=validation.error.amount/ /field field property=cc_number depends=required, creditCard page=1 arg0 key=validation.error.ccnumber/ /field !-- End of validation rules for each bean -- /form /formset /form-validation Part of my jsp: only the getAttribute type of error shows up. the html:errors parts are empty. I'd like to have them work so I can dump the getAttribute(errors) part. form action=../donation3/donation3.do method=post input type=hidden name=pagename value=donationPage/ p style=background-color:rgb(0,255,255); font-size:large;Donor Information/p All errors with Java script %= request.getAttribute(errors) == null ? No errors : request.getAttribute(errors) %br/ All errors with strut tag html:errors/br/ Single error report with strut tag html:errors property=firstname/ p*Indicates required field/p p On 11/7/06, Romu [EMAIL PROTECTED] wrote: validations are linked to xml files: action path=/XXX name=yourForm scope=session validate=false type=yyyAction forward name=succees path=/WEB-INF/jsp/success.jsp/ /action with name tag, struts will look in validation.xml files to see the rules etc , and it wil generates the javascript . check if u got javascript validation code in your jsp ? 2006/11/7, Thom Burnett [EMAIL PROTECTED]: What are common simple mistakes that would prevent validation from occuring? I've got a simple struts application that runs correctly except that validation doesn't occur. The form info is accepted as correct when required information is missing. I'm trying to figure out what's missing from my setup or understanding. The ValidatorForm (my extension) class has appropriate get and set functions for all fields. (The fields are spread over 3 jsp pages, if that matters.) I've added the validator plugin to the struts-config, the action mapping has validate=true and a valid input path, added the validation-rules and validation.xml file, added the resource properties file with the standard errors (taken from the struts file). If I write my own validate method in the form bean that validation works properly. It's my understanding that if I'm using the validation
Re: Starting validation
Chris, Following your advice, I've now found the proper settings for my resource file. With that fixed I can take out the sub class' validate() method and still get a set of errors. However, getting errors still depopulate's the form's fields. Again, I can fix that by overriding the validate method (calling super) and that's not a horrible solution - since it doesn't cost much work. But I don't think it should be necessary and am wondering what's not set up right that would cause that problem. As near as I can see the form is being named and associated correctly but I must be missing something. On 11/7/06, Christopher Schultz [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thom, struts-config.xml: This looks good. request.setAttribute(sessionForm, this) ; // If I don't do this the form will be blank after an error. You really shouldn't have to do this. The form bean in the session will be called donorBean because of the value of the name attribute in your action mapping in struts-config.xml. request.setAttribute(errors, actionErrors) ; You shouldn't have to do this, either. Struts should be putting this ActionErrors object into the request for you. This is all you should need: return actionErrors ; My validations.xml file - working partially When you say partially, you mean that your form is re-displayed when validation doesn't pass, right? It's just that your errors do not show up and the form fields are blank. I think your validation is probably okay, but let's see. arg0 key=validation.error.firstname/ Do all of these properties actually exist in this file: /WEB-INF/ErrorMessages.properties (this is where you indicated your message resources were). I'm not sure what is the standard way to do this, but I have my message resources in my WEB-INF/classes directory, and I specify it like this: message-resources parameter=ApplicationMessages null=false / You might try adding 'null=false' to see if you start getting messages like '???en_US.validation.error.firstname???' in your pages. If you get these messages, it means that struts can't find your error messages, but they are being properly generated and saved into the request. html:errors/ This ought to print /something/. My guess is a properties file loading problem (see above). Hope that helps, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFUMCr9CaO5/Lv0PARAg8pAJ0ToTTuxR2wC09xbRLXrGTNKfwa7ACfUhBI 41L+o5dayknOJDxN2PrQOl8= =T+ly -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Starting validation
Here's a snippet of one of the jsp files. I'd almost forgotten myself that I added the getAttribute(sessionForm) some time ago. I'm working on an application that uses several jsp pages to gather one set of information before it really does anything with it. Ideally, the first form gets validated before the user can get to the second form and that must be validated before the third And of course all of this must work if the user hits the browser's navigation buttons. Before I added any validation at all, I found that when I filled out one page and went on to the next page, I'd lose whatever was added in the first page unless I put the sessionForm as an attribute. Simply specifying that the form was in session scope didn't keep the information around. In my research, this was something that some people did and others didn't. I wasn't clear on when or why. So maybe the use of the Javascript to fill input values is killing something that struts is trying to do. I just know that without this, I didn't keep information between requests. The reason for overriding the validate method was to set the sessionForm attribute. I was also just starting to try to use the ValidateForm.setPage(). As I understand it, that field (page) should enable me to have validation done only on parts of the form. I haven't seen any examples and am just trying it out as we speak. % AllDonationInformationFormBean3 sessionForm = (AllDonationInformationFormBean3)request.getAttribute(sessionForm) ; if(sessionForm == null) sessionForm = new AllDonationInformationFormBean3() ; % body center h1New Account Registration/h1 /center form action=../donation3/donation3.do method=post input type=hidden name=pagename value=donationPage/ p style=background-color:rgb(0,255,255); font-size:large;Donor Information/p html:errors/br/ p*Indicates required field/p p Title select name=salutation/ option value=Mr.Mr/option option value=Ms.Ms/option /select /p P font color=red*First Name: /font input type=text name=firstname value=%= sessionForm.getFirstname() % /br/ font color=red*Last Name:/font input type=text name=last value=%= sessionForm.getLast() % /br/ On 11/7/06, Christopher Schultz [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thom, Thom Burnett wrote: With that fixed I can take out the sub class' validate() method and still get a set of errors. That's good, I guess. What do you mean, the subclass's validate method? I didn't realize that you had multiple levels of validation being performed. However, getting errors still depopulate's the form's fields. That shouldn't happen. Lemmie look at your JSP source again... Ah. You didn't provide any of the HTML code that contains the input elements. Could you post a representative sample? Again, I can fix that by overriding the validate method (calling super) and that's not a horrible solution Yeah... don't do that. You should be able to work directly with the bean that you already have. No need to go through any acrobatics like this. Just so I know, what is the superclass for this bean and what does its super.validate method do that you aren't doing in the subclass? Come to think of it, why are you overriding the superclass's validate method in the first place? And... if you are overriding it, why aren't you calling that superclass method first thing in your overidden method implementation? If you have a base form bean that contains some utility methods, you should not have to call super.validate(). On the other hand, if you have a super class bean that needs its validation done /too/, then you should do this: public ActionErrors validate(...) { ActionErrors errors = super.validate(...); // Now perform your own validation. return errors; } As near as I can see the form is being named and associated correctly but I must be missing something. It looks like validate() is being called, otherwise you wouldn't be getting error messages. Since your action mapping names the bean /and/ the input attribute is associated with the mapping (i.e. there's no redirect), that bean (including its invalid input) ought to be available in the session (as per your 'scope' preference). Post your JSP code around your input elements and let me have a look. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFUM8a9CaO5/Lv0PARAsyxAJ9YtgRv+A4MQgUi5n4zppJVkTcFIQCfeM3n yrmuTXI0ttkeoceXAFyr/aQ= =wyhj -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]