RE: Requiredif validator
Hi Pablo Try using validwhen instead - I think rewquiredif was deprecated. I changed all mine and you can achive the same thing although your logic might have to be turned around a bit. Here's an example: form name=completionForm extends=commonBankForm field property=registeredTitle depends=required arg key=completion.registered.title/ /field field property=titleNo depends=validwhen arg key=completion.title.no/ var var-nametest/var-name var-value( (registeredTitle == 'false') or ((registeredTitle == 'true') and (*this* != null)) )/var-value /var /field Richard Gundersen Java Developer Email: [EMAIL PROTECTED] Phone: 01618302398 Fax: 01618342536 London Scottish Bank plc 24 Mount Street Manchester M2 3LS -Original Message- From: Pablo Vázquez Blázquez [mailto:[EMAIL PROTECTED] Sent: Friday, September 07, 2007 12:30 PM To: user@struts.apache.org Subject: Requiredif validator Hi all! I´m trying to validate two fields that depends on another field. What I was doing in S1 is (for field in): field property=in depends=requiredif msg name=validwhen key=ErrorMessages.applicationIdRepresent.sameReference/ arg position=0 key=ProcessorHTTPDetails.in/ msg name=mask key=ProcessorHTTPDetails.in.help/ var var-namefield[0]/var-name var-valueeditParams/var-value /var var var-namefieldTest[0]/var-name var-valueNOTNULL/var-value /var /field But now in S2, there is no requiredif validator :( Any idea about how can I do to get the same validation effect? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ *** Disclaimer *** This electronic communication is confidential and for the exclusive use of the addressee. It may contain private and confidential information. The information, attachments and opinions contained in this E-mail are those of its author only and do not necessarily represent those of London Scottish Bank PLC or any other members of the London Scottish Group. If you are not the intended addressee, you are prohibited from any disclosure, distribution or further copying or use of this communication or the information in it or taking any action in reliance on it. If you have received this communication in error please notify the Information Security Manager at [EMAIL PROTECTED] as soon as possible and delete the message from all places in your computer where it is stored. We utilise virus scanning software but we cannot guarantee the security of electronic communications and you are advised to check any attachments for viruses. We do not accept liability for any loss resulting from any corruption or alteration of data or importation of any virus as a result of receiving this electronic communication. Replies to this E-mail may be monitored for operational or business reasons. London Scottish Bank PLC is regulated by the Financial Services Authority. __ This email has been scanned by the MessageLabs Email Security System. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Requiredif validator
Hi Richard, Looking at http://struts.apache.org/2.x/docs/validation.html I don´t see there was validwhen validator... Besides that, the example you gave me is for Struts 1, isn´t it? I need an Strut2 one. Thanks. Gundersen, Richard escribió: Hi Pablo Try using validwhen instead - I think rewquiredif was deprecated. I changed all mine and you can achive the same thing although your logic might have to be turned around a bit. Here's an example: form name=completionForm extends=commonBankForm field property=registeredTitle depends=required arg key=completion.registered.title/ /field field property=titleNo depends=validwhen arg key=completion.title.no/ var var-nametest/var-name var-value( (registeredTitle == 'false') or ((registeredTitle == 'true') and (*this* != null)) )/var-value /var /field Richard Gundersen Java Developer Email: [EMAIL PROTECTED] Phone: 01618302398 Fax: 01618342536 London Scottish Bank plc 24 Mount Street Manchester M2 3LS -Original Message- From: Pablo Vázquez Blázquez [mailto:[EMAIL PROTECTED] Sent: Friday, September 07, 2007 12:30 PM To: user@struts.apache.org Subject: Requiredif validator Hi all! I´m trying to validate two fields that depends on another field. What I was doing in S1 is (for field in): field property=in depends=requiredif msg name=validwhen key=ErrorMessages.applicationIdRepresent.sameReference/ arg position=0 key=ProcessorHTTPDetails.in/ msg name=mask key=ProcessorHTTPDetails.in.help/ var var-namefield[0]/var-name var-valueeditParams/var-value /var var var-namefieldTest[0]/var-name var-valueNOTNULL/var-value /var /field But now in S2, there is no requiredif validator :( Any idea about how can I do to get the same validation effect? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ *** Disclaimer *** This electronic communication is confidential and for the exclusive use of the addressee. It may contain private and confidential information. The information, attachments and opinions contained in this E-mail are those of its author only and do not necessarily represent those of London Scottish Bank PLC or any other members of the London Scottish Group. If you are not the intended addressee, you are prohibited from any disclosure, distribution or further copying or use of this communication or the information in it or taking any action in reliance on it. If you have received this communication in error please notify the Information Security Manager at [EMAIL PROTECTED] as soon as possible and delete the message from all places in your computer where it is stored. We utilise virus scanning software but we cannot guarantee the security of electronic communications and you are advised to check any attachments for viruses. We do not accept liability for any loss resulting from any corruption or alteration of data or importation of any virus as a result of receiving this electronic communication. Replies to this E-mail may be monitored for operational or business reasons. London Scottish Bank PLC is regulated by the Financial Services Authority. __ This email has been scanned by the MessageLabs Email Security System. - 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: requiredif help?
try using validwhen - something like: field property=lunchFrom depends=validwhen arg key=Lunch from resource=false/ var var-nametest/var-name var-value((lunchBreak == 'N') or (*this* != null))/var-value /var /field field property=lunchTo depends=validwhen arg key=Lunch to resource=false/ var var-nametest/var-name var-value((lunchBreak == 'N') or (*this* != null))/var-value /var /field -Original Message- From: Mallik [mailto:[EMAIL PROTECTED] Sent: Tuesday, 10 October 2006 4:49 PM To: user@struts.apache.org Subject: requiredif help? HI friends In my form, i have to validate two fields,if another check box is not selected, means if the user checked no lunch break,lunch from and lunch to are not required,else both are monadatory. i hope requiredif suits for this, if so, give me some sample code or any artical for this or is there any better solution for this,help for that ur's Mallik -- View this message in context: http://www.nabble.com/requiredif-help--tf2414782.html#a6731043 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: requiredif help?
Thank you friend no i got some idea, i hope it will work ur's Mallik -- View this message in context: http://www.nabble.com/requiredif-help--tf2414782.html#a6731806 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: requiredif help?
HI friend thanks for help i go through it but it is not working right this is my code snipet validation.xml - field property=lunchFrom depends=validwhen arg0 key=label.lunchFrom resource=false/ var var-nametest/var-name var-value(noLunch == 'Y')/var-value /var /field field property=lunchTo depends=validwhen arg0 key=label.lunchTo resource=false/ var var-nametest/var-name var-value(noLunch == 'Y')/var-value /var /field -- this jsp code snipet --- tr td class=rightsubheading1font class=redastrik*/fontbean:message key=label.weeklyWorkingDays//td td class=leftsubheading1 html:select property=weeklyWorkingDays styleClass=formlistsmall html:option value=Select/html:option html:option value=11/html:option html:option value=22/html:option html:option value=33/html:option html:option value=44/html:option html:option value=55/html:option html:option value=66/html:option /html:select /td td class=rightsubheading1bean:message key=label.noLunch//td td class=leftsubheading1html:checkbox property=noLunch value=Y/check/td /tr tr td class=rightsubheading1bean:message key=label.lunchFrom//td td class=leftsubheading1 html:select property=lunchFrom styleClass=formlistsmall size=1 html:option value=Select/html:option html:option value=11:0011:00/html:option html:option value=11:0511:05/html:option html:option value=11:1011:10/html:option html:option value=11:1511:15/html:option html:option value=11:2011:20/html:option html:option value=11:2511:25/html:option html:option value=11:3011:30/html:option html:option value=11:3511:35/html:option html:option value=11:4011:40/html:option html:option
RE: requiredif help?
try: var-value((lunchBreak == null) or (*this* != null))/var-value above may work better for checkboxes which do not submit a value when unchecked... Some handy points about validwhen: 1. use it in place of required 2. I often come up with a invalidwhen logic and then reverse it for validwhen e.g. 1. lunch from is invalid if: (lunchFrom == null and lunchbreak != null) now turn it around... 2. lunch from is valid if: (lunchFrom != null or lunchbreak == null) Hope that helps Paul -Original Message- From: Strachan, Paul [mailto:[EMAIL PROTECTED] Sent: Tuesday, 10 October 2006 4:58 PM To: Struts Users Mailing List Subject: RE: requiredif help? try using validwhen - something like: field property=lunchFrom depends=validwhen arg key=Lunch from resource=false/ var var-nametest/var-name var-value((lunchBreak == 'N') or (*this* != null))/var-value /var /field field property=lunchTo depends=validwhen arg key=Lunch to resource=false/ var var-nametest/var-name var-value((lunchBreak == 'N') or (*this* != null))/var-value /var /field -Original Message- From: Mallik [mailto:[EMAIL PROTECTED] Sent: Tuesday, 10 October 2006 4:49 PM To: user@struts.apache.org Subject: requiredif help? HI friends In my form, i have to validate two fields,if another check box is not selected, means if the user checked no lunch break,lunch from and lunch to are not required,else both are monadatory. i hope requiredif suits for this, if so, give me some sample code or any artical for this or is there any better solution for this,help for that ur's Mallik -- View this message in context: http://www.nabble.com/requiredif-help--tf2414782.html#a6731043 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: requiredif
Hi Erik, Actually, I do have a more complicated scenario. I tried your idea using JavaScript to set the action and it worked perfectly. Thanks a lot. -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 20, 2005 12:51 PM To: Struts Users Mailing List Subject: Re: requiredif tarek.nabil wrote: Thanks Erik. I like the idea of using the same action with different URLs but how do you do that? The only way I can think of is changing the action of the form when clicking any of the buttons using JavaScript, is that what you meant? Well that is a common way to do it. I was thinking of the typical case of add vs. update -- two actions that could share the same page, ActionForm and Action. Here you don't need JavaScript. There are two GET requests for the page, something like /controller/viewAdd and /controller/viewUpdate. When the user requests the add page, you set the form action to /controller/saveAdd, and when the user requests the update page, you set the form action to /controller/saveUpdate, or something like that, dynamically: html:form action=${action} focus=foo However, it sounds like you have a more complicated scenario, so I don't know whether you would be forced to change the action URL with JavaScript in your case. Erik Actually, for our client, clientside validations are more important than server-side ones. The reason I'm doing server-side validations is that I know that client-side validations can be circumvented and I don't want that to cause an error screen to appear. As for validwhen, I think it's worth giving it a shot to see if it can be plugged in as a custom validator. -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 20, 2005 8:50 AM To: Struts Users Mailing List Subject: Re: requiredif tarek.nabil wrote: Hi Erik, Actually after some reasoning about the application I came to a conclusion that I will not use the integration between Struts and the Validator framework. I might still use the ready made validators, but I will call them explicitly. Yeah don't forget that you can still use the Validator plugin on the server side, even if you don't use the Validator brand of ActionForms. See Rick Reumann's site for examples of this (if I'm not mistaken; I know he uses this technique). The reason is, the pages in the application are designed to do search, add, edit and delete functionalities in the same page. We do this using the same form, and the button the user presses is what determines the operation. This makes all the validations kind of conditional. For example, the id will be mandatory if you're deleting but the name will be mandatory if you're adding and so on. As a result, to support this, I will have to declare all my required validations using requiredif since usually most validations depend on required. Well, there is an easy way to conquer this problem -- you just use multiple action mappings for the same Action that use the same ActionForm. All you need is a different URL then. Each action mapping has a different name (an alias to the same ActionForm) -- triggering a different section of your validation.xml file to be used for validation. This way you can validate only the fields required for the given use case, and yet you have a single Action and a single ActionForm, and even a single form JSP. Have you considered this? Since requiredif does not have a clientside script part, that means I will only benefit from server side validation, that's problem number one. But client side validation is only a luxury for the user while server side validation is mandatory, so I don't understand your statement here. Problem number two is that declaring all required validations as requiredif will be very time consuming, since the syntax for requiredif is a bit awkward and very verbose. Adding the fact that requiredif is not supported in the version I'm using makes the integration almost meaningless. As you see, no clientside, time consuming simple validations and above all, it's not currently working. That led me to the decision to just write my own validation code in the validate method. I'm really confused about what you are trying to do here. requiredif is for a case where, for example, you have a drop down box paired with a text field. You only want the text field value to be validated if the drop down box value is equal to foo. Are you trying to use it to accomplish something else? (Like what I describe in my second paragraph?) The only thing that would make me change my mind is if I were able to use validwhen with 1.1b2. Only then will this make sense, although even in this case I would still have to write my own clientside validations. Or wouldn't I? Depends on whether validwhen generates javascript for clientside validation. Does it do
RE: requiredif
Thanks Erik. I like the idea of using the same action with different URLs but how do you do that? The only way I can think of is changing the action of the form when clicking any of the buttons using JavaScript, is that what you meant? Actually, for our client, clientside validations are more important than server-side ones. The reason I'm doing server-side validations is that I know that client-side validations can be circumvented and I don't want that to cause an error screen to appear. As for validwhen, I think it's worth giving it a shot to see if it can be plugged in as a custom validator. -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 20, 2005 8:50 AM To: Struts Users Mailing List Subject: Re: requiredif tarek.nabil wrote: Hi Erik, Actually after some reasoning about the application I came to a conclusion that I will not use the integration between Struts and the Validator framework. I might still use the ready made validators, but I will call them explicitly. Yeah don't forget that you can still use the Validator plugin on the server side, even if you don't use the Validator brand of ActionForms. See Rick Reumann's site for examples of this (if I'm not mistaken; I know he uses this technique). The reason is, the pages in the application are designed to do search, add, edit and delete functionalities in the same page. We do this using the same form, and the button the user presses is what determines the operation. This makes all the validations kind of conditional. For example, the id will be mandatory if you're deleting but the name will be mandatory if you're adding and so on. As a result, to support this, I will have to declare all my required validations using requiredif since usually most validations depend on required. Well, there is an easy way to conquer this problem -- you just use multiple action mappings for the same Action that use the same ActionForm. All you need is a different URL then. Each action mapping has a different name (an alias to the same ActionForm) -- triggering a different section of your validation.xml file to be used for validation. This way you can validate only the fields required for the given use case, and yet you have a single Action and a single ActionForm, and even a single form JSP. Have you considered this? Since requiredif does not have a clientside script part, that means I will only benefit from server side validation, that's problem number one. But client side validation is only a luxury for the user while server side validation is mandatory, so I don't understand your statement here. Problem number two is that declaring all required validations as requiredif will be very time consuming, since the syntax for requiredif is a bit awkward and very verbose. Adding the fact that requiredif is not supported in the version I'm using makes the integration almost meaningless. As you see, no clientside, time consuming simple validations and above all, it's not currently working. That led me to the decision to just write my own validation code in the validate method. I'm really confused about what you are trying to do here. requiredif is for a case where, for example, you have a drop down box paired with a text field. You only want the text field value to be validated if the drop down box value is equal to foo. Are you trying to use it to accomplish something else? (Like what I describe in my second paragraph?) The only thing that would make me change my mind is if I were able to use validwhen with 1.1b2. Only then will this make sense, although even in this case I would still have to write my own clientside validations. Or wouldn't I? Depends on whether validwhen generates javascript for clientside validation. Does it do that? And do you think this is possible? I won't comment on the client side validation, because I don't use it. The only client side validation I tend to use (if at all) is a blank field check when the form happens to be very large, unless of course my customer wants something else. If the customer wants something else, I give him a desktop application. :) I also don't know about retrofitting validwhen for 1.1, but again, the idea arises that perhaps you could embed validwhen (or something just like it) as a custom validator? Does the version of Struts you are using support custom validators? Hope that helps, Erik Thanks -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 19, 2005 7:54 PM To: Struts Users Mailing List Subject: Re: requiredif Oh, I'm sorry. I pulled that from the last release of 1.1. Zoinks, you are stuck with a pre-1.1 version? Perhaps you could write a custom validator plugin that basically does the same thing? tarek.nabil wrote: Hi Erik, I tried it and it didn't work. I checked out the validator and struts jar files and it turned out
Re: requiredif
tarek.nabil wrote: Thanks Erik. I like the idea of using the same action with different URLs but how do you do that? The only way I can think of is changing the action of the form when clicking any of the buttons using JavaScript, is that what you meant? Well that is a common way to do it. I was thinking of the typical case of add vs. update -- two actions that could share the same page, ActionForm and Action. Here you don't need JavaScript. There are two GET requests for the page, something like /controller/viewAdd and /controller/viewUpdate. When the user requests the add page, you set the form action to /controller/saveAdd, and when the user requests the update page, you set the form action to /controller/saveUpdate, or something like that, dynamically: html:form action=${action} focus=foo However, it sounds like you have a more complicated scenario, so I don't know whether you would be forced to change the action URL with JavaScript in your case. Erik Actually, for our client, clientside validations are more important than server-side ones. The reason I'm doing server-side validations is that I know that client-side validations can be circumvented and I don't want that to cause an error screen to appear. As for validwhen, I think it's worth giving it a shot to see if it can be plugged in as a custom validator. -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 20, 2005 8:50 AM To: Struts Users Mailing List Subject: Re: requiredif tarek.nabil wrote: Hi Erik, Actually after some reasoning about the application I came to a conclusion that I will not use the integration between Struts and the Validator framework. I might still use the ready made validators, but I will call them explicitly. Yeah don't forget that you can still use the Validator plugin on the server side, even if you don't use the Validator brand of ActionForms. See Rick Reumann's site for examples of this (if I'm not mistaken; I know he uses this technique). The reason is, the pages in the application are designed to do search, add, edit and delete functionalities in the same page. We do this using the same form, and the button the user presses is what determines the operation. This makes all the validations kind of conditional. For example, the id will be mandatory if you're deleting but the name will be mandatory if you're adding and so on. As a result, to support this, I will have to declare all my required validations using requiredif since usually most validations depend on required. Well, there is an easy way to conquer this problem -- you just use multiple action mappings for the same Action that use the same ActionForm. All you need is a different URL then. Each action mapping has a different name (an alias to the same ActionForm) -- triggering a different section of your validation.xml file to be used for validation. This way you can validate only the fields required for the given use case, and yet you have a single Action and a single ActionForm, and even a single form JSP. Have you considered this? Since requiredif does not have a clientside script part, that means I will only benefit from server side validation, that's problem number one. But client side validation is only a luxury for the user while server side validation is mandatory, so I don't understand your statement here. Problem number two is that declaring all required validations as requiredif will be very time consuming, since the syntax for requiredif is a bit awkward and very verbose. Adding the fact that requiredif is not supported in the version I'm using makes the integration almost meaningless. As you see, no clientside, time consuming simple validations and above all, it's not currently working. That led me to the decision to just write my own validation code in the validate method. I'm really confused about what you are trying to do here. requiredif is for a case where, for example, you have a drop down box paired with a text field. You only want the text field value to be validated if the drop down box value is equal to foo. Are you trying to use it to accomplish something else? (Like what I describe in my second paragraph?) The only thing that would make me change my mind is if I were able to use validwhen with 1.1b2. Only then will this make sense, although even in this case I would still have to write my own clientside validations. Or wouldn't I? Depends on whether validwhen generates javascript for clientside validation. Does it do that? And do you think this is possible? I won't comment on the client side validation, because I don't use it. The only client side validation I tend to use (if at all) is a blank field check when the form happens to be very large, unless of course my customer wants something else. If the customer wants something else, I give him a desktop application. :) I also don't
Re: requiredif
!-- requiredif -- validator name=requiredif classname=org.apache.struts.validator.FieldChecks method=validateRequiredIf methodParams=java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest msg=errors.required/ Erik tarek.nabil wrote: Hi, I'm stuck with Struts 1.1b2 and I need to do some conditional validation. AFAIK, the way to do this for this version is using the requiredif validator. The problem is, I cannot find any reference information on how to add this validator to the validator-rules.xml configuration file. Please advise on how to do this and if there's a better way to do this with this old version. For example, is it possible to configure the old Struts/Validator versions to use validwhen? Any help is appreciated. Tarek Nabil - 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: requiredif
Thanks Erik. I was wondering, is there a client side JavaScript part? Also, is it possible to use validwhen with the old versions of struts (1.1b2). Thanks for your help. -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 19, 2005 3:24 PM To: Struts Users Mailing List Subject: Re: requiredif !-- requiredif -- validator name=requiredif classname=org.apache.struts.validator.FieldChecks method=validateRequiredIf methodParams=java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest msg=errors.required/ Erik tarek.nabil wrote: Hi, I'm stuck with Struts 1.1b2 and I need to do some conditional validation. AFAIK, the way to do this for this version is using the requiredif validator. The problem is, I cannot find any reference information on how to add this validator to the validator-rules.xml configuration file. Please advise on how to do this and if there's a better way to do this with this old version. For example, is it possible to configure the old Struts/Validator versions to use validwhen? Any help is appreciated. Tarek Nabil - 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: requiredif
Hi Erik, I tried it and it didn't work. I checked out the validator and struts jar files and it turned out that the org.apache.struts.validator.FieldChecks class does not exist in either of them. Is it possible that it was introduced after 1.1b2? I'm sure it's in RC1 because I'm using the documentation shipped in 1.1RC1. Thanks again for your help. -Original Message- From: tarek.nabil Sent: Tuesday, April 19, 2005 7:41 PM To: Struts Users Mailing List Subject: RE: requiredif Thanks Erik. I was wondering, is there a client side JavaScript part? Also, is it possible to use validwhen with the old versions of struts (1.1b2). Thanks for your help. -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 19, 2005 3:24 PM To: Struts Users Mailing List Subject: Re: requiredif !-- requiredif -- validator name=requiredif classname=org.apache.struts.validator.FieldChecks method=validateRequiredIf methodParams=java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest msg=errors.required/ Erik tarek.nabil wrote: Hi, I'm stuck with Struts 1.1b2 and I need to do some conditional validation. AFAIK, the way to do this for this version is using the requiredif validator. The problem is, I cannot find any reference information on how to add this validator to the validator-rules.xml configuration file. Please advise on how to do this and if there's a better way to do this with this old version. For example, is it possible to configure the old Struts/Validator versions to use validwhen? Any help is appreciated. Tarek Nabil - 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: requiredif
Oh, I'm sorry. I pulled that from the last release of 1.1. Zoinks, you are stuck with a pre-1.1 version? Perhaps you could write a custom validator plugin that basically does the same thing? tarek.nabil wrote: Hi Erik, I tried it and it didn't work. I checked out the validator and struts jar files and it turned out that the org.apache.struts.validator.FieldChecks class does not exist in either of them. Is it possible that it was introduced after 1.1b2? I'm sure it's in RC1 because I'm using the documentation shipped in 1.1RC1. Thanks again for your help. -Original Message- From: tarek.nabil Sent: Tuesday, April 19, 2005 7:41 PM To: Struts Users Mailing List Subject: RE: requiredif Thanks Erik. I was wondering, is there a client side JavaScript part? Also, is it possible to use validwhen with the old versions of struts (1.1b2). Thanks for your help. -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 19, 2005 3:24 PM To: Struts Users Mailing List Subject: Re: requiredif !-- requiredif -- validator name=requiredif classname=org.apache.struts.validator.FieldChecks method=validateRequiredIf methodParams=java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest msg=errors.required/ Erik tarek.nabil wrote: Hi, I'm stuck with Struts 1.1b2 and I need to do some conditional validation. AFAIK, the way to do this for this version is using the requiredif validator. The problem is, I cannot find any reference information on how to add this validator to the validator-rules.xml configuration file. Please advise on how to do this and if there's a better way to do this with this old version. For example, is it possible to configure the old Struts/Validator versions to use validwhen? Any help is appreciated. Tarek Nabil - 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: requiredif
tarek.nabil wrote: Hi Erik, Actually after some reasoning about the application I came to a conclusion that I will not use the integration between Struts and the Validator framework. I might still use the ready made validators, but I will call them explicitly. Yeah don't forget that you can still use the Validator plugin on the server side, even if you don't use the Validator brand of ActionForms. See Rick Reumann's site for examples of this (if I'm not mistaken; I know he uses this technique). The reason is, the pages in the application are designed to do search, add, edit and delete functionalities in the same page. We do this using the same form, and the button the user presses is what determines the operation. This makes all the validations kind of conditional. For example, the id will be mandatory if you're deleting but the name will be mandatory if you're adding and so on. As a result, to support this, I will have to declare all my required validations using requiredif since usually most validations depend on required. Well, there is an easy way to conquer this problem -- you just use multiple action mappings for the same Action that use the same ActionForm. All you need is a different URL then. Each action mapping has a different name (an alias to the same ActionForm) -- triggering a different section of your validation.xml file to be used for validation. This way you can validate only the fields required for the given use case, and yet you have a single Action and a single ActionForm, and even a single form JSP. Have you considered this? Since requiredif does not have a clientside script part, that means I will only benefit from server side validation, that's problem number one. But client side validation is only a luxury for the user while server side validation is mandatory, so I don't understand your statement here. Problem number two is that declaring all required validations as requiredif will be very time consuming, since the syntax for requiredif is a bit awkward and very verbose. Adding the fact that requiredif is not supported in the version I'm using makes the integration almost meaningless. As you see, no clientside, time consuming simple validations and above all, it's not currently working. That led me to the decision to just write my own validation code in the validate method. I'm really confused about what you are trying to do here. requiredif is for a case where, for example, you have a drop down box paired with a text field. You only want the text field value to be validated if the drop down box value is equal to foo. Are you trying to use it to accomplish something else? (Like what I describe in my second paragraph?) The only thing that would make me change my mind is if I were able to use validwhen with 1.1b2. Only then will this make sense, although even in this case I would still have to write my own clientside validations. Or wouldn't I? Depends on whether validwhen generates javascript for clientside validation. Does it do that? And do you think this is possible? I won't comment on the client side validation, because I don't use it. The only client side validation I tend to use (if at all) is a blank field check when the form happens to be very large, unless of course my customer wants something else. If the customer wants something else, I give him a desktop application. :) I also don't know about retrofitting validwhen for 1.1, but again, the idea arises that perhaps you could embed validwhen (or something just like it) as a custom validator? Does the version of Struts you are using support custom validators? Hope that helps, Erik Thanks -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 19, 2005 7:54 PM To: Struts Users Mailing List Subject: Re: requiredif Oh, I'm sorry. I pulled that from the last release of 1.1. Zoinks, you are stuck with a pre-1.1 version? Perhaps you could write a custom validator plugin that basically does the same thing? tarek.nabil wrote: Hi Erik, I tried it and it didn't work. I checked out the validator and struts jar files and it turned out that the org.apache.struts.validator.FieldChecks class does not exist in either of them. Is it possible that it was introduced after 1.1b2? I'm sure it's in RC1 because I'm using the documentation shipped in 1.1RC1. Thanks again for your help. -Original Message- From: tarek.nabil Sent: Tuesday, April 19, 2005 7:41 PM To: Struts Users Mailing List Subject: RE: requiredif Thanks Erik. I was wondering, is there a client side JavaScript part? Also, is it possible to use validwhen with the old versions of struts (1.1b2). Thanks for your help. -Original Message- From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 19, 2005 3:24 PM To: Struts Users Mailing List Subject: Re: requiredif !-- requiredif -- validator name=requiredif classname
Re: requiredif combined with other validation rules
I don't think that's surprising behaviour. It sounds like what you really need is a 'maskIf' test. You could possibly roll your own from the requiredif and mask. On 10/25/2004 05:12 PM David Schneider wrote: hi. i'm using struts 1.1 and have a question about combining requiredif with other validation rules. i have field property=zip depends=requiredif, mask msg name=requiredif key=CustomerInfoForm.zip.invalid/ msg name=mask key=CustomerInfoForm.zip.invalid/ var var-namefield[0]/var-name var-valuecountry/var-value /var var var-namefieldTest[0]/var-name var-valueEQUAL/var-value /var var var-namefieldValue[0]/var-name var-value840/var-value /var var var-namemask/var-name var-value${uszipmask}/var-value /var field if a user chooses a country other than 840 (usa) and leaves the zip blank, then the form passes validation. however, if he chooses a country other than 840 and enters something in the zip field then the mask is applied to that value. i would like the mask rule to be bypassed also if the country isn't 840. is this possible? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]