RE: Validation help: One struts form, multiple actions
My bad. Missed that. How is it blowing out? Q > -Original Message- > From: Chaudhary, Harsh [mailto:[EMAIL PROTECTED] > Sent: Monday, May 08, 2006 1:27 PM > To: Struts Users Mailing List; [EMAIL PROTECTED] > Subject: RE: Validation help: One struts form, multiple actions > > > I intentionally used /ClientA for my form name as I said, I have one > struts form but multiple actions using that same form. So while > validating, I want to validate only the fields associated with a > particular action e.g. for ClientA action, I want to validate only > fields for ClientA and same for ClientB i.e. I want to validate only > Client B fields for ClientB action. All the fields are using the same > struts form. > > That is why I am using a ValidatorActionForm instead of a > ValidatorForm. > > Harsh. > > -Original Message- > From: Quinn Stone [mailto:[EMAIL PROTECTED] > Sent: Monday, May 08, 2006 3:26 PM > To: 'Struts Users Mailing List' > Subject: RE: Validation help: One struts form, multiple actions > > > Your form name in validation.xml should be "InputDataForm" (no leading > slash), > not "/ClientA". > > > -Original Message- > > From: Chaudhary, Harsh [mailto:[EMAIL PROTECTED] > > Sent: Monday, May 08, 2006 1:16 PM > > To: Struts Users Mailing List > > Subject: Validation help: One struts form, multiple actions > > > > > > Hi, > > I am having some trouble with struts validation. Here's the case: > > > > I have multiple actions corresponding to multiple pages. > > I have only one struts form for all these actions. > > > > I would appreciate it if someone could tell me how to set up my > > validation. I am using ValidatorActionForm for my struts > > form. My action > > class extends from Action. > > > > Here's a snippet of my struts-config.xml: > > > > > > > type="xxx.xxx.presentation.struts.action.ClientaAction" > > name="InputDataForm" > > scope="request" > > validate="true" > > input=".app.clienta"> > > > > > > > > > > > type="xxx.xxx.presentation.struts.action.ClientbAction" > //This is diff > > from "/ClientA" type > > name="InputDataForm" > > scope="request" > > validate="true" > > input=".app.clientb"> > > > > > > > > Snippet from my validation.xml: > > > > > > > > > > > > > > > > > > mask > > ${nameMask} > > > > > > > > > > > > > > I thought this should be straight forward, i.e., associate your > > validation formName to actions and set validate to true in > > struts-config.xml. But, its blowing out. Any ideas? > > > > Thanks, > > Harsh. > > > > > - > > 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] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validation help: One struts form, multiple actions
Your form name in validation.xml should be "InputDataForm" (no leading slash), not "/ClientA". > -Original Message- > From: Chaudhary, Harsh [mailto:[EMAIL PROTECTED] > Sent: Monday, May 08, 2006 1:16 PM > To: Struts Users Mailing List > Subject: Validation help: One struts form, multiple actions > > > Hi, > I am having some trouble with struts validation. Here's the case: > > I have multiple actions corresponding to multiple pages. > I have only one struts form for all these actions. > > I would appreciate it if someone could tell me how to set up my > validation. I am using ValidatorActionForm for my struts > form. My action > class extends from Action. > > Here's a snippet of my struts-config.xml: > > > type="xxx.xxx.presentation.struts.action.ClientaAction" > name="InputDataForm" > scope="request" > validate="true" > input=".app.clienta"> > > > > > type="xxx.xxx.presentation.struts.action.ClientbAction" //This is diff > from "/ClientA" type > name="InputDataForm" > scope="request" > validate="true" > input=".app.clientb"> > > > > Snippet from my validation.xml: > > > > > > > > > mask > ${nameMask} > > > > > > > I thought this should be straight forward, i.e., associate your > validation formName to actions and set validate to true in > struts-config.xml. But, its blowing out. Any ideas? > > Thanks, > Harsh. > > - > 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]
RE: page validation in wizzard app
You can use the flow: POPULATE1-> JSP1 -> ACTION1 -> POPULATE2 -> JSP2 -> ACTION2 -> POPULATE3 -> JSP3 All of the POPULATE actions have "validate=false" in the config. So, if validation fails after JSP2 is submitted, it forwards to POPULATE2 (ACTION2 has input="POPULATE2" set), which won't try to validate. It makes for more (2x!) actions, but also groups actions logically. POPULATE2 gets things ready for JSP2, and ACTION2 does something with the form from JSP2, and doesn't care about JSP3 at all. That way, you can move the xxx2 page somewhere else, and just have to change the mapping in the config (assuming they're not named 1, 2, 3, that could get a little confusing). Not sure you'd want to change things at this point, but that's one way to approach the problem. Q > -Original Message- > From: Jakub Milkiewicz [mailto:[EMAIL PROTECTED] > Sent: Sunday, May 07, 2006 2:14 PM > To: Struts Users Mailing List > Subject: Re: page validation in wizzard app > > > Hi Richard. > I can't because of autovalidation. Remember that all my > action have the same > actionForm which is storred in session. > If validation fails i am forwarded to previous action but > this action is not > even executed cause before this previous action can be > invoked validation > process occurs. Page parameter isn't changed and validation > process fails > again... > If validation fails i do not enter any action's execute() method. > > 2006/5/7, Richard Yee <[EMAIL PROTECTED]>: > > > > Jakub, > > Why can't you reset the page attribute to the appropriate > value in your > > Action classes when validation fails. > > > > -Richard > > > > Richard Yee wrote: > > > Jakub, > > > I think the more elegant solution is to do the validations in the > > > ActionForm validate method and also use a hidden static 'page' > > > variable in the JSP. Your Action.execute method should be > fairly small > > > and mainly have code that calls business delegates and > that necessary > > > for determining where to forward to. > > > > > > -Richard > > > > > > > > > Jakub Milkiewicz wrote: > > >> Hi > > >> I have a wizzard application with 5 screens. All user inputs are > > >> collected > > >> in one bean, which is named: viewBean and is stored in > HTTP session. > > >> So each action has the same formBean - viewBean. > > >> I use commons-validator and viewBean properties to validate are > > >> present in > > >> validation.xml with page attributes. > > >> ViewBean extends ValidatorForm and it's validation occurs > > >> automatically - i > > >> have validation set to true for all ACTIONS. > > >> The structure of my app is: > > >> Populate view -> jsp ->populate view ->jsp ->populate > view -> jsp ... > > >> Population of view happens in ACTION class and can consists of > > >> retrieving > > >> some data from DB, sets these data in HTTP request. > > >> After population process i forward to appropriate jsp to > give user a > > >> chance > > >> to fill the form and to present population process results as for > > >> example > > >> options in . > > >> If form is correct i go to another action which populate > view for a > > next > > >> screen (jsp). > > >> If form is not filled correctly i need to show it again, > but i can not > > >> forward to jsp - i need to forward to action that > prepares the form - > > >> that's > > >> why i have my input parameter of tag set to action which > > >> populate > > >> the view - previous action. > > >> I have a problem with page attribute. Please take a look at the > > >> sample of > > >> processing in my app: > > >> ACTION1 -> JSP1 ->ACTION2 -> JSP2 ->Action3 ->JSP3 ... > > >> Let's assume that user submits form in JSP2 to action3. After > > ActionForm > > >> bean population, page property is set to 2. Next, > validation fails in > > >> Action3 and input parameter of forwards user > to ACTION2. > > >> Before execute method in Action2 is invoked, ActionForm > (viewBean) > > >> validation occurs. The page attribute is still set to 2 ! and > > >> commons-validator tries to validate properties that has page > > >> attribute set > > >> to 2.Obviously validation fails and control is forwarded > to Action1. > > >> Action1 > > >> also has validation set to true and validation of > ActionForm occurs > > >> again > > >> with page =2. > > >> Validation fails and control is forwarded to ... > > >> Does anyone have any idea to solve the problem. > > >> My idea is to not to use hidden page parameter in each > jsp action but > > >> set > > >> page property of viewBean in each Action: for ACTION2 sets it to > > 2, for > > >> Action3 sets it to 3 ... > > >> and to override validate method in viewBean: > > >> > > >> public ActionErrors validate( > > >>ActionMapping mapping, > > >>HttpServletRequest request) { > > >>ActionErrors errors = super.validate(mapping,request); > > >>if(errors != null && errors.size() > 0 ) > > >> page--; > > >>return errors; > > >> }
Validwhen and whitespace
Struts 1.2.9, Validator 1.2.0. If I used the "required" validation, when the user enters whitespace in a form field, the validation fails. However, when using "validwhen" it seems that whitespace is accepted. In the validation I'm using (below), if the user leaves lastName empty, an error is generated. However, if the user enters whitespace, the validation passes. Is this expected behavior? I would expect "validwhen" to trim, but it doesn't seem to. Here's the validation. I'm trying to ensure that lastName is entered if any of the other parent info is entered: test (parent[1].firstName == null) and (parent[1].phoneData == "false")) and (parent[1].email == null)) and (parent[1].preferredName == null)) or (*this* != null)) maxlength${nameLen} mask ${nameMask} - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Servlet Filter?
Frank, thanks for the link to javawebparts. The source code there helped me a great deal. Dakota, thanks for that very detailed explanation of creating my own dispatcher, but I chose to use a filter for now. I'm just not ready to go change the buttons and existing actions at the moment. I'll look at the code you provided and maybe if I get ahead of timeline (yah, right) I'll make the move. So, I'm the big ding bat. I totally whiffed on the "what are you going to map to" comment made by Frank because I was under the impression that you could define with something like "/Enroll*.do". I decided to just do a path.startswith("/Enroll") to determine whether to make the check for the session bean. It seems to be working. I started out with configurable paths and ignorelists, but then thought "you know what, this is a very specialized filter, I don't want someone to fiddle with configuration parms without thinking about it." My next question is whether there's a mechanism by which I can stick an ActionError in the request so that the error page can display a message to the user using the familiar Struts tag. Q > -Original Message- > From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] > Sent: Friday, April 07, 2006 10:03 PM > To: Struts Users Mailing List > Subject: Re: Servlet Filter? > > > Yeah, that's all reasonable. Well, back to the filter then :) > > One thing you may want to do is have a look at the filters in > Java Web > Parts (http://javawebparts.sourceforge.net). We have them all > implemented with some added flexibility in mapping to paths. > At least > that way you can only fire it when really appropriate... well... in > reality, it's *still* firing, but hopefully doing a lot less > work than > it might otherwise need to. You can rip off the code for that extra > ability (it's in the FilterHelpers class). > > Then again, I may be micro-optimizing here... maybe for what > your filter > is doing it won't be that heavyweight anyway. Sounds like > that may be > the case. So, even if you mapped it to *.do for instance, it > might not > really be a problem. > > Frank > > Quinn Stone wrote: > > OK. I contemplated creating a base class, but didn't like > the idea of having to > > create a basically empty Action class for Actions that use > ActionForward to > > forward to a jsp for display without calling an Action. > And, frankly, thought it > > would be more complex to go learn the order of method calls of > > LookupDispatchAction to figure out what to override and > when and how I return > > without bypassing some necessary processing. Sometimes I > like the easy way out > > (as long as it's not crappy). > > > > Q > > > > -Original Message- > > From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] > > Sent: Friday, April 07, 2006 8:24 PM > > To: Struts Users Mailing List > > Subject: Re: Servlet Filter? > > > > > > Hi Quinn, > > > > Quinn Stone wrote: > >> 1. Does the Servlet filter seem a good solution? > > > > Yes, but not quite as described, and ironically its because of the > > answer to #2 :) > > > >> 2. If I throw an EnrollmentDingBat exception from said > Servlet Filter, will a > >> handler defined in catch it? My > suspicion is that the > > filter > >> might executing too early, before struts mechanics cut in. > > > > No, it won't. As you suspect, the filter fires before > Struts gets involved. > > > > However, what you *can* do, is simply forward somewhere > from the filter. > > It could be straight to a JSP, or it could be to an > Action mapping, > > whatever is appropriate. > > > > I think using a filter is generally a decent idea, but one thing to > > consider: what are you going to map it to? It sounds like > you have many > > possible URLs that you would need to check, hence the > reason for wanting > > some "central" checkpoint in the first place. The problem is, the > > filter is of course going to fire for *any* mapped request > > indiscriminately. While filters, unless poorly written, > tend to not add > > a horrible amount of overhead, you may not want to add any > at all where > > it isn't necessary. So, onto #3... > > > >> No, three questions: > >> > >> 3. Any better ideas? > > > > I would probably do it instead with a custom Action base > class that your > > other Actions extend from. Then, only extend from it those Act
RE: Validator rule question
Oh. I guess you're right. Maybe you'll have to write your own validator plugin? Or check the date in the action? Q -Original Message- From: Rivka Shisman [mailto:[EMAIL PROTECTED] Sent: Saturday, April 08, 2006 11:02 PM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: Validator rule question Hi Quinn, As much as I understand the "validwhen" is more like an enhanced "requiredif", but I need that the "date" rule on my property be checked only when my other property has value "X". I don't think the "validwhen" can solve this. Am I right? Rivka -Original Message- From: Quinn Stone [mailto:[EMAIL PROTECTED] Sent: Saturday, April 08, 2006 8:06 PM To: 'Struts Users Mailing List' Subject: RE: Validator rule question Rivka, look into the "validwhen" validation. I think that should do the trick. Q -Original Message- From: Rivka Shisman [mailto:[EMAIL PROTECTED] Sent: Saturday, April 08, 2006 9:24 AM To: Struts Users Mailing List Subject: Validator rule question Hello Friends, I have a DynaValidatorForm in which there 2 String properties: action and student_birth_date. I have a date validation like this: datePatternStrict MM/yy I need that the validation above to depend on the value of the "action" property in the Form (i.e. if action equals "create" or "update" then do the validation, else ignore it) How can I do that? Thanks Rivka - 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]
RE: Validator rule question
Rivka, look into the "validwhen" validation. I think that should do the trick. Q -Original Message- From: Rivka Shisman [mailto:[EMAIL PROTECTED] Sent: Saturday, April 08, 2006 9:24 AM To: Struts Users Mailing List Subject: Validator rule question Hello Friends, I have a DynaValidatorForm in which there 2 String properties: action and student_birth_date. I have a date validation like this: datePatternStrict MM/yy I need that the validation above to depend on the value of the "action" property in the Form (i.e. if action equals "create" or "update" then do the validation, else ignore it) How can I do that? Thanks Rivka - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Servlet Filter?
OK. I contemplated creating a base class, but didn't like the idea of having to create a basically empty Action class for Actions that use ActionForward to forward to a jsp for display without calling an Action. And, frankly, thought it would be more complex to go learn the order of method calls of LookupDispatchAction to figure out what to override and when and how I return without bypassing some necessary processing. Sometimes I like the easy way out (as long as it's not crappy). Q -Original Message- From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] Sent: Friday, April 07, 2006 8:24 PM To: Struts Users Mailing List Subject: Re: Servlet Filter? Hi Quinn, Quinn Stone wrote: > 1. Does the Servlet filter seem a good solution? Yes, but not quite as described, and ironically its because of the answer to #2 :) > 2. If I throw an EnrollmentDingBat exception from said Servlet Filter, will a > handler defined in catch it? My suspicion is that the filter > might executing too early, before struts mechanics cut in. No, it won't. As you suspect, the filter fires before Struts gets involved. However, what you *can* do, is simply forward somewhere from the filter. It could be straight to a JSP, or it could be to an Action mapping, whatever is appropriate. I think using a filter is generally a decent idea, but one thing to consider: what are you going to map it to? It sounds like you have many possible URLs that you would need to check, hence the reason for wanting some "central" checkpoint in the first place. The problem is, the filter is of course going to fire for *any* mapped request indiscriminately. While filters, unless poorly written, tend to not add a horrible amount of overhead, you may not want to add any at all where it isn't necessary. So, onto #3... > No, three questions: > > 3. Any better ideas? I would probably do it instead with a custom Action base class that your other Actions extend from. Then, only extend from it those Actions where this check is needed. I mean, if you determine its needed for all of them, or nearly all of them, then I'd probably go with the filter. If you can narrow it down to just a handful though, the custom base Action might be a better answer. > Q HTH, Frank -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! - 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]
Servlet Filter?
I have a wizard-type flow for an enrollment process. I use a session scoped EnrollmentBean to store the form-beans as they are gathered through the process. If the user cancels the enrollment anywhere along the way, I remove the EnrollmentBean from the session and forward to a "Your enrollment has been cancelled" page. If, after canceling, the pesky user uses history or the back button and tries to keep going with their cancelled enrollment, we have an obvious problem. I was starting off with the idea of simply checking for the EnrollmentBean in my actions, and if it's gone, forwarding to a "You ding-bat, you are trying to finish off a cancelled enrollment" page. It seemed like it was going to work, even though I hated having the "EnrollmentBean check" code in a bunch of different places. Well, the whole thing fell apart when it came to Actions that were just ForwardActions: Nowhere to intercept execution (that I know of) before the jsp tries to use the EnrollmentBean. Rats. Now I'm contemplating using a Servlet Filter (never tried that before) to check for the EnrollmentBean in the session for all my Enroll*.do paths, and throw my own EnrollmentDingBat exception if there's no Enrollment Bean. Then use a to handle it. Two questions to those of you who know more than I do (this is my first Struts application): 1. Does the Servlet filter seem a good solution? 2. If I throw an EnrollmentDingBat exception from said Servlet Filter, will a handler defined in catch it? My suspicion is that the filter might executing too early, before struts mechanics cut in. No, three questions: 3. Any better ideas? Q - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat SSL Enabled - Popup information on pages : Contains se cure and non secure items
Vijay: Did you check for references to other resources, not just "links"? I think that if you have images, external javascript, stylesheets, etc. that are referenced with "http" you'll get that message. Q -Original Message- From: vijay venkataraman [mailto:[EMAIL PROTECTED] Sent: Friday, March 31, 2006 9:57 AM To: Struts Users Mailing List Subject: Re: Tomcat SSL Enabled - Popup information on pages : Contains se cure and non secure items Richard thanks for information. This happens only with IE. There is no content in the page, which refers to a http request. Pages come fine with Firefox and Mozilla. I understand that the server will be strained, if i use https for all the pages. -Vijay Venkataraman Yee, Richard K CTR DMDC wrote: >The behavior you describe is a feature of the browser. You cannot prevent >the browser from displaying it when there are non-secure links when viewing >a secure page. One think you could do is make everything https, but then >your server may be strained by the extra use of https. > >-Richard > > >-Original Message- >From: vijay venkataraman [mailto:[EMAIL PROTECTED] >Sent: Friday, March 31, 2006 6:42 AM >To: Struts Users Mailing List >Subject: Tomcat SSL Enabled - Popup information on pages : Contains secure >and non secure items > > >I just enabled SSL in Tomcat Server 5.5.9 for my application. When i >fetch a page i get a popup with message >"This page contains both secure and non secure items. Do you want to >display the non secure items." > >When i did a view source on the page, there is a flash component which >points to http url of macro media site, but when i click on a different >link in the page which has no reference to the protocol (http or https) >that navigates to another page, again i get the popup message. When i >did a view source, i don't see any reference to http or there is no url >in the page which starts with http/https. Can anyone let me know how to >fix this or show me some leads to this problem. > >Using Struts 1.2.4 and viewing on IE 6.0.2800.1106 + with latest patches. > >Thanks, >Vijay Venkataraman > > --DISCLAIMER-- This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. - 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]
I apologize for maintaining human standards
Larry Meadors, Rick Reumann, recently departed Jester Moose. Thank you. Jonathon Revusky, Dakota Jack, James Mitchell, and anyone else who has really got their knickers in a knot over these threads. C'mon. I'm tired of reading this stuff. My problem is I don't know how to dev/null a thread, I guess. Or even what it means. I think maybe we should have for users, for developers, and a new for those that want to have pissing contests. Speaking of saturation... Q
Re-use field validations?
Is there any way to define the validation for a common form field once in validation.xml and re-use the validation in other blocks? This would allow validation.xml to be updated in one place rather than many places, if validation requirements change for a field that is used on many forms. It would also help ensure that I (or others) won't accidentally incorrectly code different validations for the same field on different forms. The benefits will compound if I start writing custom validation routines. I am new to Struts, and this is my first project using it, so I hope I'm not missing something obvious. Thanks, Quinn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]