Re: Problems with validator
Sorry, my question already was answered in another thread. The next time, I will search for before to ask. 2006/11/15, Juanjo Cuadrado <[EMAIL PROTECTED]>: Hi, Can I use the forms of kinds "ValidatorActionForm" and "ValidatorForm" with the feature validator? I'm using this feature but it only works when my forms are of kinds "DynaValidatorForm".
Problems with validator
Hi, Can I use the forms of kinds "ValidatorActionForm" and "ValidatorForm" with the feature validator? I'm using this feature but it only works when my forms are of kinds "DynaValidatorForm".
Re: struts tiles and validator framework
Madhav Bhargava ha scritto: Let me elaborate my problem and the reason i have posted this to this list: I am using tiles with JSF. So i have just one layout.jsp. This file has the tag and other JSP's just get inserted into the respective place holders. All of this works just fine. The problem comes when i am trying to use Struts client side validator framework along with the combination of tiles + JSF. In the validator framework - validation.xml file will require a form name and then all the fields and their respective validations. Will this mean that if there are 40 different forms that use the same layout tile will need to have fields uniquely named? I thought this was a big ask and therefore wanted to know how tiles and struts validator framework work together. The problem is that the validator framework and Tiles do not work together! You should see the validator framework as it works on the composed page, and not on each "tile". Anyway, even if you don't use validator, each field in an html form should be uniquely named. Does it answer your question? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts tiles and validator framework
Let me elaborate my problem and the reason i have posted this to this list: I am using tiles with JSF. So i have just one layout.jsp. This file has the tag and other JSP's just get inserted into the respective place holders. All of this works just fine. The problem comes when i am trying to use Struts client side validator framework along with the combination of tiles + JSF. In the validator framework - validation.xml file will require a form name and then all the fields and their respective validations. Will this mean that if there are 40 different forms that use the same layout tile will need to have fields uniquely named? I thought this was a big ask and therefore wanted to know how tiles and struts validator framework work together. Thanks for the reply. ~madhav On 11/7/06, Antonio Petrelli <[EMAIL PROTECTED]> wrote: Madhav Bhargava ha scritto: > Since i am using struts tiles there is always going to be one form. > How can > i then use these 2 together? Wait a moment, what's the connection between Tiles and the use of only one form? That's not true. Probably you wanted to say that you have one form and the fields of that form is spread across different JSP pages, right? In this case probably you have to create a big big ActionForm that contains all fields, or create one ActionForm for each resulting page. Anyway I don't know Validator very well, so maybe someone else can help you more than me. Ciao Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- When I tell the truth, it is not for the sake of convincing those who do not know it, but for the sake of defending those that do
Re: struts tiles and validator framework
Madhav Bhargava ha scritto: Since i am using struts tiles there is always going to be one form. How can i then use these 2 together? Wait a moment, what's the connection between Tiles and the use of only one form? That's not true. Probably you wanted to say that you have one form and the fields of that form is spread across different JSP pages, right? In this case probably you have to create a big big ActionForm that contains all fields, or create one ActionForm for each resulting page. Anyway I don't know Validator very well, so maybe someone else can help you more than me. Ciao Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
struts tiles and validator framework
Hi All, I am using struts tiles for laying out all the pages. I am wondering how i can use struts client validator framework with struts tiles. The validation.xml file requires form name and then within the form tag we define the individual fields along with the respective validations. Since i am using struts tiles there is always going to be one form. How can i then use these 2 together? Any help/guidence will be appreciated. ~madhav -- When I tell the truth, it is not for the sake of convincing those who do not know it, but for the sake of defending those that do
Re: validator framework
Yariel Ramos Moreno wrote: How can I validate a form field to accept numbers from 1 to 99 or an underscore (_) using the validator framework. The application is in Struts 1.1. If you didn't have the requirement to accept underscore, intRange would be what you were looking for. With that requirement, you'd have to use a regex, or write a custom validation rule. See the 'mask' validation rule [1] for the regex approach. L. [1] http://struts.apache.org/1.2.9/userGuide/dev_validator.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator framework
Check this document, slide 30 by Shang Shin. http://www.javapassion.com/j2ee/StrutsValidationFramework_speakernoted.pdf I think it's a good explanation...Check it out. Check intRange key, how he works with it. For dominicans, cubans are our brothers...we share historical events! I hope this could help you. On 10/20/06, Yariel Ramos Moreno <[EMAIL PROTECTED]> wrote: Hi, How can I validate a form field to accept numbers from 1 to 99 or an underscore (_) using the validator framework. The application is in Struts 1.1. Best Regards. __ XIII Convención Científica de Ingeniería y Arquitectura 28/noviembre al 1/diciembre de 2006 Cujae, Ciudad de la Habana, Cuba http://www.cujae.edu.cu/eventos/convencion -- -- Sócrates Medina -- -"Looking ahead!"
validator framework
Hi, How can I validate a form field to accept numbers from 1 to 99 or an underscore (_) using the validator framework. The application is in Struts 1.1. Best Regards. __ XIII Convención Científica de Ingeniería y Arquitectura 28/noviembre al 1/diciembre de 2006 Cujae, Ciudad de la Habana, Cuba http://www.cujae.edu.cu/eventos/convencion
Re: Validator framework javascript error messages
Puneet Lakhina wrote: Hi, I have the following key value pair in ApplicationResource.properties required = {0} is required. I used this when I was doing only server side validation, to display a list of error messages when some validation failed. Now Im using the to do the same thing on client side also. But my problem is that now i get error messages like Name is required Status is requried in an alert box on the jsp page when i submit with some validation errors. I would like to maybe use different error messages for what is displayed on the client side. Is that possible?? Following is my validation.xml Im using struts 1.1 AFAIK, there's no way to use different validation messages client-side and server-side. However, what you should be able to do is remove the markup from the error messages you have, and use the server-side error reporting tags to insert it. How you achieve the server-side part of that depends on how you display your error messages. If you use html:errors, you can use the errors.header, errors.footer, errors.prefix and errors.suffix resources [1]. If you use the html:messages tag [2], you would put the markup directly into your JSP / view. L. [1] http://struts.apache.org/1.2.9/userGuide/struts-html.html#errors [2] http://struts.apache.org/1.2.9/userGuide/struts-html.html#messages - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validator framework javascript error messages
Hi, I have the following key value pair in ApplicationResource.properties required = {0} is required. I used this when I was doing only server side validation, to display a list of error messages when some validation failed. Now Im using the to do the same thing on client side also. But my problem is that now i get error messages like Name is required Status is requried in an alert box on the jsp page when i submit with some validation errors. I would like to maybe use different error messages for what is displayed on the client side. Is that possible?? Following is my validation.xml Im using struts 1.1 -- Puneet
Re: Problem with validator framework in LookupDispatchAction
Yariel Ramos Moreno wrote: Hi all: I have a LookupDispatchAction which can be submitted by two buttons (Update and Restore). I need to validate this form only when Update button is pressed. The form field to validate is required and most be integer. The required condition works fine, using the requiredIf validation with a hidden field to check the pressed button (ask for the pressed button and if the value is 1 (Update) then validate, else (value 2 for Restore) don't do anything). If the value in the field is not an integer, the validator framework triggers an exception no matter which button were pressed. What can I do to make this validation using the validator framework? What exception is triggered? What does the form bean look like? I'm guessing that you have a form property declared as 'integer' and the exception is occurring when you have non-integer input. In that case, try changing for form bean property to String. If that's not it, post the relevant snippets of configuration, including your form bean declaration and implementation, your validation rules and relevant JSP code. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with validator framework in LookupDispatchAction
Hi all: I have a LookupDispatchAction which can be submitted by two buttons (Update and Restore). I need to validate this form only when Update button is pressed. The form field to validate is required and most be integer. The required condition works fine, using the requiredIf validation with a hidden field to check the pressed button (ask for the pressed button and if the value is 1 (Update) then validate, else (value 2 for Restore) don't do anything). If the value in the field is not an integer, the validator framework triggers an exception no matter which button were pressed. What can I do to make this validation using the validator framework? Thanks in advance. __ XIII Convención Científica de Ingeniería y Arquitectura 28/noviembre al 1/diciembre de 2006 Cujae, Ciudad de la Habana, Cuba http://www.cujae.edu.cu/eventos/convencion
Re: Problem with validator
Not surprising, given where these config files came from :) Actually, we upgraded Struts a while back and I doubt anyone looked at the config files, but I'll do that tomorrow, thanks for pointing it out :) (And yes, I fixed the validator problem... had to change the parameter list in validator-rules.xml to match the signatures of the FieldCheck class' check methods). Frank -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM/Yahoo: fzammetti MSN: [EMAIL PROTECTED] Author of "Practical Ajax Projects With Java Technology" (2006, Apress, ISBN 1-59059-695-1) Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! On Wed, October 4, 2006 5:50 pm, Wendy Smoak wrote: > On 10/4/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: > >> Hello... trying to use Commons Validator 1.3.0 with Struts 1.2.9, seeing >> the following error... anyone have any ideas? Everything seems fine >> until >> the first check... config files follow trace. Thanks! > > In the config files you posted, the DOCTYPEs don't match the versions > you claim to be using. Struts-config in particular looks odd, with > 1.1 in the public identifier, but an old 1.0 jakarta url for the dtd. > Both validation config files are using the 1.1.3 dtd. > > This is probably unrelated to the actual error, but is enough to make > me stop looking. :) > > -- > Wendy > > - > 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: Problem with validator
On 10/4/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: Hello... trying to use Commons Validator 1.3.0 with Struts 1.2.9, seeing the following error... anyone have any ideas? Everything seems fine until the first check... config files follow trace. Thanks! In the config files you posted, the DOCTYPEs don't match the versions you claim to be using. Struts-config in particular looks odd, with 1.1 in the public identifier, but an old 1.0 jakarta url for the dtd. Both validation config files are using the 1.1.3 dtd. This is probably unrelated to the actual error, but is enough to make me stop looking. :) -- Wendy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with validator
Hold up, think I found it... trying to pass Validator as well, doesn't match the signature in FieldChecks... -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM/Yahoo: fzammetti MSN: [EMAIL PROTECTED] Author of "Practical Ajax Projects With Java Technology" (2006, Apress, ISBN 1-59059-695-1) Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! On Wed, October 4, 2006 5:43 pm, Frank W. Zammetti wrote: > Hello... trying to use Commons Validator 1.3.0 with Struts 1.2.9, seeing > the following error... anyone have any ideas? Everything seems fine until > the first check... config files follow trace. Thanks! > > > 20061004-17:29:17,766 DEBUG [Servlet.Engine.Transports : 0] > (ModuleUtils.java:167) Get module name for path > /testView/testValidation.do > 20061004-17:29:17,766 DEBUG [Servlet.Engine.Transports : 0] > (ModuleUtils.java:191) Module name found: default > 20061004-17:29:17,812 DEBUG [Servlet.Engine.Transports : 0] > (RequestProcessor.java:172) Processing a 'POST' for path > '/testView/testValidation' > 20061004-17:29:17,812 DEBUG [Servlet.Engine.Transports : 0] > (RequestUtils.java:200) Looking for ActionForm bean instance in scope > 'request' under attribute key 'valForm' > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (RequestUtils.java:294) Creating new DynaActionForm instance of type > 'org.apache.struts.validator.DynaValidatorForm' > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (RequestUtils.java:300) --> > DynaActionForm[dynaClass=valForm,firstName=,lastName=] > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (RequestProcessor.java:339) Storing ActionForm bean instance in scope > 'request' under attribute key 'valForm' > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (RequestProcessor.java:805) Populating bean properties from this request > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (BeanUtilsBean.java:795) > BeanUtils.populate(DynaActionForm[dynaClass=valForm,firstName=,lastName=], > {firstName=[Ljava.lang.String;@7c51607, > lastName=[Ljava.lang.String;@73fd607}) > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (BeanUtilsBean.java:876) > setProperty(DynaActionForm[dynaClass=valForm,firstName=,lastName=], > firstName, []) > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (ConvertUtilsBean.java:418) Convert string '' to class 'java.lang.String' > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (ConvertUtilsBean.java:426) Using converter > [EMAIL PROTECTED] > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (BeanUtilsBean.java:876) > setProperty(DynaActionForm[dynaClass=valForm,firstName=,lastName=], > lastName, []) > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (ConvertUtilsBean.java:418) Convert string '' to class 'java.lang.String' > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (ConvertUtilsBean.java:426) Using converter > [EMAIL PROTECTED] > 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] > (RequestProcessor.java:948) Validating input form properties > 20061004-17:29:17,891 DEBUG [Servlet.Engine.Transports : 0] > (ValidatorResources.java:453) Form 'valForm' found in formset 'default' > for locale 'en_US_DO' > 20061004-17:29:17,938 ERROR [Servlet.Engine.Transports : 0] > (DynaValidatorForm.java:112) No such validation method: > org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, > org.apache.commons.validator.ValidatorAction, > org.apache.commons.validator.Field, > org.apache.struts.action.ActionMessages, > javax.servlet.http.HttpServletRequest) > org.apache.commons.validator.ValidatorException: No such validation > method: > org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, > org.apache.commons.validator.ValidatorAction, > org.apache.commons.validator.Field, > org.apache.struts.action.ActionMessages, > javax.servlet.http.HttpServletRequest) > at > org.apache.commons.validator.ValidatorAction.loadValidationMethod(ValidatorAction.java:603) > at > org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:533) > at org.apache.commons.validator.Field.validateForRule(Field.java:766) > at org.apache.commons.validator.Field.validate(Field.java:846) > at org.apache.commons.validator.Form.validate(Form.java:290) > at org.apache.commons.validator.Validator.validate(Valid
Problem with validator
Hello... trying to use Commons Validator 1.3.0 with Struts 1.2.9, seeing the following error... anyone have any ideas? Everything seems fine until the first check... config files follow trace. Thanks! 20061004-17:29:17,766 DEBUG [Servlet.Engine.Transports : 0] (ModuleUtils.java:167) Get module name for path /testView/testValidation.do 20061004-17:29:17,766 DEBUG [Servlet.Engine.Transports : 0] (ModuleUtils.java:191) Module name found: default 20061004-17:29:17,812 DEBUG [Servlet.Engine.Transports : 0] (RequestProcessor.java:172) Processing a 'POST' for path '/testView/testValidation' 20061004-17:29:17,812 DEBUG [Servlet.Engine.Transports : 0] (RequestUtils.java:200) Looking for ActionForm bean instance in scope 'request' under attribute key 'valForm' 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (RequestUtils.java:294) Creating new DynaActionForm instance of type 'org.apache.struts.validator.DynaValidatorForm' 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (RequestUtils.java:300) --> DynaActionForm[dynaClass=valForm,firstName=,lastName=] 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (RequestProcessor.java:339) Storing ActionForm bean instance in scope 'request' under attribute key 'valForm' 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (RequestProcessor.java:805) Populating bean properties from this request 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (BeanUtilsBean.java:795) BeanUtils.populate(DynaActionForm[dynaClass=valForm,firstName=,lastName=], {firstName=[Ljava.lang.String;@7c51607, lastName=[Ljava.lang.String;@73fd607}) 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (BeanUtilsBean.java:876) setProperty(DynaActionForm[dynaClass=valForm,firstName=,lastName=], firstName, []) 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (ConvertUtilsBean.java:418) Convert string '' to class 'java.lang.String' 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (ConvertUtilsBean.java:426) Using converter [EMAIL PROTECTED] 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (BeanUtilsBean.java:876) setProperty(DynaActionForm[dynaClass=valForm,firstName=,lastName=], lastName, []) 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (ConvertUtilsBean.java:418) Convert string '' to class 'java.lang.String' 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (ConvertUtilsBean.java:426) Using converter [EMAIL PROTECTED] 20061004-17:29:17,828 DEBUG [Servlet.Engine.Transports : 0] (RequestProcessor.java:948) Validating input form properties 20061004-17:29:17,891 DEBUG [Servlet.Engine.Transports : 0] (ValidatorResources.java:453) Form 'valForm' found in formset 'default' for locale 'en_US_DO' 20061004-17:29:17,938 ERROR [Servlet.Engine.Transports : 0] (DynaValidatorForm.java:112) No such validation method: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest) org.apache.commons.validator.ValidatorException: No such validation method: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest) at org.apache.commons.validator.ValidatorAction.loadValidationMethod(ValidatorAction.java:603) at org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:533) at org.apache.commons.validator.Field.validateForRule(Field.java:766) at org.apache.commons.validator.Field.validate(Field.java:846) at org.apache.commons.validator.Form.validate(Form.java:290) at org.apache.commons.validator.Validator.validate(Validator.java:354) at org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorForm.java:110) at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:950) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:207) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110) at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174) at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictL
Validate a multiple html:select with validator framework
I have a multiple html:select and i need to validate it with validator framework. The attribute in the ActionForm is an array of strings. private String[] subtemas= new String[]{} The validation that i'm using is required.This validation works with others form fields This is the code of html:select in jsp page: Thanks
exists any way to know when validator framework turn on?
Hi Do exists any way to know when validator framework turn on? I think i could ask by a var in the session or something like that. Thanks for any help you could give me
Issue with Validator DTD location
Hi, I am running my Struts web app on WSAD 5.1.1. I get compilation and run-time 'File Not Found' errors when the app looks up my validator_1_1_3.dtd and validator_1_1.dtd files. The exact error is: java.io.FileNotFoundException: C:\Program Files\IBM\WebSphere Studio\Application Developer IE\WEB-INF\validator_1_1_3.dtd (The system cannot find the path specified) As you can see, the app always seem to lookup the files in my WSAD installation folders. I've tried the following combinations of DTD references in my validator-rule.xml and validation.xml file. 1."validator_1_1.dtd" 2."/WEB-INF/validator_1_1.dtd" 3."../WEB-INF/validator_1_1.dtd" and all combinations of DTD locations 1.In WSAD and WEB-INF 2.Not In WSAD but in WEB-INF 3.In WSAD but not in WEB-INF Has anyone encountered this issue before? If yes, can you let me know how I can fix this, and what the exact issue might be? Thanks, Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validate an hmt:select with validator framework
Hi I tried with the solution of Laurie, and that work's. Now the problem is that i have two kinds of html:select The first html:select, load an Collection of Value Objects This is the code: --- The field in the ValidatorForm is: private String categoria With this type of html:select i can validate with validator framework. The second type is an htm:select wich input is a list of Enumerations --- With this second html:select, i can not validate. The field in the ValidatorForm is private String proceso; Thanks On 9/25/06, Wendy Smoak <[EMAIL PROTECTED]> wrote: On 9/25/06, Laurie Harper <[EMAIL PROTECTED]> wrote: > You said your form property was of type 'Long'. By default, a null input > value will be turned into 0, so the required validator rule will think > the property has a value. Good catch, Laurie! I completely missed the type... probably didn't read that far. :) -- Wendy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validate an hmt:select with validator framework
On 9/25/06, Laurie Harper <[EMAIL PROTECTED]> wrote: You said your form property was of type 'Long'. By default, a null input value will be turned into 0, so the required validator rule will think the property has a value. Good catch, Laurie! I completely missed the type... probably didn't read that far. :) -- Wendy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validate an hmt:select with validator framework
You said your form property was of type 'Long'. By default, a null input value will be turned into 0, so the required validator rule will think the property has a value. You should generally use String-typed form bean properties, but if you need to keep it as Long, you'll want to configure BeanUtils not to convert null to 0. See the BeanUtils documentation for details on how to do that (you need to register a customized instance of the converter for type Long). L. Heidy Gutiérrez Guzmán wrote: Hi I try ---. and that also does't work If you have any more idea, i would be grateful On 9/25/06, Chris Pratt <[EMAIL PROTECTED]> wrote: According to your code, the default value is the String "null", not ---. You might want to try setting that to an empty value, e.g. --- (*Chris*) On 9/25/06, Heidy Gutiérrez Guzmán <[EMAIL PROTECTED]> wrote: > > Hi > > I need to validate an html:select with validator framework > > This is the code that i have > > > > > --- > > "nombre"> > > > > I need have a default value that is " ---" , but i need validate that this > > value does'nt selected. > > The code in the Validator form is > private Long categoria; > > I tried to use the required validation, but that does'nt work, i think > because the html:select have the "---" default value > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validate an hmt:select with validator framework
Hi I try ---. and that also does't work If you have any more idea, i would be grateful On 9/25/06, Chris Pratt <[EMAIL PROTECTED]> wrote: According to your code, the default value is the String "null", not ---. You might want to try setting that to an empty value, e.g. --- (*Chris*) On 9/25/06, Heidy Gutiérrez Guzmán <[EMAIL PROTECTED]> wrote: > > Hi > > I need to validate an html:select with validator framework > > This is the code that i have > > > > > --- > > "nombre"> > > > > I need have a default value that is " ---" , but i need validate that this > > value does'nt selected. > > The code in the Validator form is > private Long categoria; > > I tried to use the required validation, but that does'nt work, i think > because the html:select have the "---" default value > >
Re: Validate an hmt:select with validator framework
According to your code, the default value is the String "null", not ---. You might want to try setting that to an empty value, e.g. --- (*Chris*) On 9/25/06, Heidy Gutiérrez Guzmán <[EMAIL PROTECTED]> wrote: Hi I need to validate an html:select with validator framework This is the code that i have --- I need have a default value that is " ---" , but i need validate that this value does'nt selected. The code in the Validator form is private Long categoria; I tried to use the required validation, but that does'nt work, i think because the html:select have the "---" default value
Re: Validate an hmt:select with validator framework
On 9/25/06, Heidy Gutiérrez Guzmán <[EMAIL PROTECTED]> wrote: I need to validate an html:select with validator framework --- I tried to use the required validation, but that does'nt work, i think because the html:select have the "---" default value More likely it's because you have value="null", which is the String "null", not the null value. Try using --- with the required validator and see if that works. -- Wendy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validate an hmt:select with validator framework
Hi I need to validate an html:select with validator framework This is the code that i have --- I need have a default value that is " ---" , but i need validate that this value does'nt selected. The code in the Validator form is private Long categoria; I tried to use the required validation, but that does'nt work, i think because the html:select have the "---" default value
Re: Validator and At Least 1 Checkbox Checked
Laurie, absolutely, use the required validation. I do that for my applications. Since he was specifically talking about length of an array, there is no such validation; but as long as a valid is present, it was submitted. Laurie Harper wrote: Can't you just use the 'required' validation rule? Or possibly a validwhen with something like *this* != null and *tihs*.length >= 1? Admittedly I haven't tried either, though. L. Paul Benedict wrote: I've always wanted this feature myself. However, no such validation exists.. but if you write it, you could share it back to the Struts community. So you'll have to add this validation yourself by override the validate() method of your form, checking the property's length; if it is not null then add your message to the existing error messages. Paul Mississippi John Hurt wrote: Can struts validator validate that at least one checkbox in a set is checked? I guess somehow it has to validate that a String[] array property of the form has size of 1 or more, but I dont know how. - 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 and At Least 1 Checkbox Checked
Can't you just use the 'required' validation rule? Or possibly a validwhen with something like *this* != null and *tihs*.length >= 1? Admittedly I haven't tried either, though. L. Paul Benedict wrote: I've always wanted this feature myself. However, no such validation exists.. but if you write it, you could share it back to the Struts community. So you'll have to add this validation yourself by override the validate() method of your form, checking the property's length; if it is not null then add your message to the existing error messages. Paul Mississippi John Hurt wrote: Can struts validator validate that at least one checkbox in a set is checked? I guess somehow it has to validate that a String[] array property of the form has size of 1 or more, but I dont know how. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator and At Least 1 Checkbox Checked
I've always wanted this feature myself. However, no such validation exists.. but if you write it, you could share it back to the Struts community. So you'll have to add this validation yourself by override the validate() method of your form, checking the property's length; if it is not null then add your message to the existing error messages. Paul Mississippi John Hurt wrote: Can struts validator validate that at least one checkbox in a set is checked? I guess somehow it has to validate that a String[] array property of the form has size of 1 or more, but I dont know how. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validator and At Least 1 Checkbox Checked
Can struts validator validate that at least one checkbox in a set is checked? I guess somehow it has to validate that a String[] array property of the form has size of 1 or more, but I dont know how.
Re: Configuring Struts Validator with Multiple Modules
On 9/14/06, Scott Smith <[EMAIL PROTECTED]> wrote: I have a struts 1.2.9 app that has several modules (assume they are named "a" and "b"). In my struts-config-a.xml file, I have a form defined as followed: My validation.xml file looks like: When I try to access the form, I get: java.lang.IllegalArgumentException: Resources cannot be null. at org.apache.commons.validator.Validator.(Validator.java:188) at org.apache.struts.validator.Resources.initValidator(Resources.java:475) at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:10 4) ... Based on some other posts, I think this is telling me it can't find any validation information for my form ("formRegister")-which I assume means that the name specified in my tag is not what validator expects to see for form within a module. I've tried "a.formRegister" in my tag and that doesn't seem to work either. I currently have a single validation.xml file. The plugin is configured in the main struts-config.xml file. I assume I can only have one incarnation of the validator plugin. Is there something I need to put in the individual module configuration files? Do I really need to have several invocations of the plugin? Yes, you need to configure the validator plugin for each module. Niall Can someone give me some hints on configuring validator in a multi-module struts app? Thanks Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Configuring Struts Validator with Multiple Modules
I have a struts 1.2.9 app that has several modules (assume they are named "a" and "b"). In my struts-config-a.xml file, I have a form defined as followed: My validation.xml file looks like: When I try to access the form, I get: java.lang.IllegalArgumentException: Resources cannot be null. at org.apache.commons.validator.Validator.(Validator.java:188) at org.apache.struts.validator.Resources.initValidator(Resources.java:475) at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:10 4) ... Based on some other posts, I think this is telling me it can't find any validation information for my form ("formRegister")-which I assume means that the name specified in my tag is not what validator expects to see for form within a module. I've tried "a.formRegister" in my tag and that doesn't seem to work either. I currently have a single validation.xml file. The plugin is configured in the main struts-config.xml file. I assume I can only have one incarnation of the validator plugin. Is there something I need to put in the individual module configuration files? Do I really need to have several invocations of the plugin? Can someone give me some hints on configuring validator in a multi-module struts app? Thanks Scott
RE: Problems with validator framework
what I would do is: 1. keep form properties as String (and consider using DynaValidatorForm) 2. use the "required,float" or "required,int" validation 3. use BeanUtils.populate method to map the form onto a typed object (property names must match) From: Heidy Gutiérrez Guzmán [mailto:[EMAIL PROTECTED] Sent: Wed 13/09/2006 11:13 PM To: user@struts.apache.org Subject: Problems with validator framework Hi I need to validate a form with fields wich data type is "int" and "float" The validation that i use is "required", but that doesn't work. The fields are initilialized with default values (o for int types) and (0.0for float types). Whit string data types, validator works fine. If somebody would help me, i would be grateful ** 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]
Problems with validator framework
Hi I need to validate a form with fields wich data type is "int" and "float" The validation that i use is "required", but that doesn't work. The fields are initilialized with default values (o for int types) and (0.0for float types). Whit string data types, validator works fine. If somebody would help me, i would be grateful
Re: conditional required in struts validator
fea jabi wrote: Have a Drop down and an input field. When user selects "Type 1" from drop down only then the input field is required. otherwise it's not a required field. Looking at the validator guide in struts maybe I have to create a new validator rule which should check if drop down value "Type 1". But not sure how to code to say that the input field is required here. How to do this? You want the 'validwhen' validation rule. See here for documentation, including an example of what you want to do: http://struts.apache.org/1.2.9/userGuide/dev_validator.html#validwhen L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator FRamework
sheetal wrote: Thanks for the help.. Yesterday I tried and it worked... But the problem now is that its message string is not coming... I had made an entry for it in applicationresoUrces.properties... BUT STILL IT'S UNABLE TO PICK IT FROM THERE.. What message string? How are you specifying it? How did you define it in your ApplictionResources.properties file? Did you deploy the resources? Are they configured correctly in struts-config.xml? L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator framework
Gomathi wrote: Hai, Is the validator framework is only for dynavalidatorform? I am using actionform using validator framework.Its not working fine how? You need to derive your form beans from ValidatorActionForm, not just ActionForm. DynaValidatorForm extends ValidatorForm, so that should be OK, but if you have custom form beans extending ActionForm you'll need to change them to extend ValidatorForm instead. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
conditional required in struts validator
Have a Drop down and an input field. When user selects "Type 1" from drop down only then the input field is required. otherwise it's not a required field. Looking at the validator guide in struts maybe I have to create a new validator rule which should check if drop down value "Type 1". But not sure how to code to say that the input field is required here. How to do this? Thanks. _ Got something to buy, sell or swap? Try Windows Live Expo ttp://clk.atdmt.com/MSN/go/msnnkwex001001msn/direct/01/?href=http://expo.live.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
validator framework
Hai, Is the validator framework is only for dynavalidatorform? I am using actionform using validator framework.Its not working fine how? Kindly regards Gomes
Re: Validator FRamework
Laurie Harper wrote: sheetal wrote: Hi All, I had problem.. I am trying to implement client side validation using Validator FRamework. I have added validator-rules.xml, and validation.xml, in my web -inf file. And made following entry in validation.xml i have also added added an entry in struts config.xml. type="com.hns.nme.frontend.apps.cmdexecution.form.SelectCommandForm" /> type="com.hns.nme.frontend.apps.cmdexecution.form.RunCommandForm" /> type="com.hns.nme.frontend.apps.cmdexecution.action.SelectCommandAction" scope="request"> type="com.hns.nme.frontend.apps.cmdexecution.action.RunCommandAction" input="/JSP/RunCommand.jsp" attribute="runCommandForm" name="runCommandForm" scope="request"> parameter="com.hns.nme.frontend.apps.cmdexecution.ApplicationResources" /> value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> Extended my form class from ValidatorActionForm. AND iN JSP PAGE i HAVE ADDED also.. Still it's not working.. Not working how? Does validation fail completely, or only on the client? It looks like you may have a mis-match between your form bean base class and the way you've specified the validation rules; ValidatorActionForm validates based on the action mapping path, not the form name. So, you either need to change your validation.xml to something like this: or switch your form beans to be derived from ValidatorForm instead of ValidatorActionForm. If server-side validation is working and it's just client-side validation that's not, do you have the html:javascript tag somewhere in your page? L. Thanks for the help.. Yesterday I tried and it worked... But the problem now is that its message string is not coming... I had made an entry for it in applicationresoUrces.properties... BUT STILL IT'S UNABLE TO PICK IT FROM THERE.. REGARDS, Sheetal - 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 FRamework
sheetal wrote: Hi All, I had problem.. I am trying to implement client side validation using Validator FRamework. I have added validator-rules.xml, and validation.xml, in my web -inf file. And made following entry in validation.xml i have also added added an entry in struts config.xml. type="com.hns.nme.frontend.apps.cmdexecution.form.SelectCommandForm" /> type="com.hns.nme.frontend.apps.cmdexecution.form.RunCommandForm" /> type="com.hns.nme.frontend.apps.cmdexecution.action.SelectCommandAction" scope="request"> parameter="com.hns.nme.frontend.apps.cmdexecution.ApplicationResources" /> value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> Extended my form class from ValidatorActionForm. AND iN JSP PAGE i HAVE ADDED also.. Still it's not working.. Not working how? Does validation fail completely, or only on the client? It looks like you may have a mis-match between your form bean base class and the way you've specified the validation rules; ValidatorActionForm validates based on the action mapping path, not the form name. So, you either need to change your validation.xml to something like this: or switch your form beans to be derived from ValidatorForm instead of ValidatorActionForm. If server-side validation is working and it's just client-side validation that's not, do you have the html:javascript tag somewhere in your page? L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator FRamework
ups, sorry i thought you were using dinaform sorry El mar, 05 de 09 de 2006 a las 13:13, Jorge Martín Cuervo escribió: > hi > > why you use > com.hns.nme.frontend.apps.cmdexecution.form.SelectCommandForm instead > java.lang.String in form-bean type? > > El mar, 05 de 09 de 2006 a las 10:48, sheetal escribió: > > > Hi All, > > I had problem.. > > I am trying to implement client side validation using Validator FRamework. > > I have added validator-rules.xml, and validation.xml, in my web -inf file. > > And made following entry in validation.xml > > > > > > > > > > > depends="required"> > > > > > > > > > > > > > > > > i have also added added an entry in struts config.xml. > > > > > > > > > type="com.hns.nme.frontend.apps.cmdexecution.form.SelectCommandForm" /> > > > type="com.hns.nme.frontend.apps.cmdexecution.form.RunCommandForm" /> > > > > > > > > > > > > > > > type="com.hns.nme.frontend.apps.cmdexecution.action.SelectCommandAction" > > scope="request"> > > > > > > > > > > > type="com.hns.nme.frontend.apps.cmdexecution.action.RunCommandAction" > > input="/JSP/RunCommand.jsp" > > attribute="runCommandForm" > > name="runCommandForm" > > scope="request"> > > > > > > > > > > > > > >> parameter="com.hns.nme.frontend.apps.cmdexecution.ApplicationResources" /> > > > > > > > >> > > value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> > > > > > > > > > > Extended my form class from ValidatorActionForm. > > AND iN JSP PAGE i HAVE ADDED > > > also.. > > > > Still it's not working.. > > > > Can anybody help me out.. > > > > > > Thanks > > > > Regards, > > Sheetal > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > -- ;-) Jorge Martin Cuervo Analista Programador Outsourcing Emarketplace deFacto Powered by Standards email <[EMAIL PROTECTED]> voz +34 985 129 820 voz +34 660 026 384
Re: Validator FRamework
hi why you use com.hns.nme.frontend.apps.cmdexecution.form.SelectCommandForm instead java.lang.String in form-bean type? El mar, 05 de 09 de 2006 a las 10:48, sheetal escribió: > Hi All, > I had problem.. > I am trying to implement client side validation using Validator FRamework. > I have added validator-rules.xml, and validation.xml, in my web -inf file. > And made following entry in validation.xml > > > > > depends="required"> > > > > > > > > i have also added added an entry in struts config.xml. > > > > type="com.hns.nme.frontend.apps.cmdexecution.form.SelectCommandForm" /> > type="com.hns.nme.frontend.apps.cmdexecution.form.RunCommandForm" /> > > > > > > > type="com.hns.nme.frontend.apps.cmdexecution.action.SelectCommandAction" > scope="request"> > > > > >type="com.hns.nme.frontend.apps.cmdexecution.action.RunCommandAction" > input="/JSP/RunCommand.jsp" > attribute="runCommandForm" > name="runCommandForm" > scope="request"> > > > > > > >parameter="com.hns.nme.frontend.apps.cmdexecution.ApplicationResources" /> > > > > > value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> > > > > > Extended my form class from ValidatorActionForm. > AND iN JSP PAGE i HAVE ADDED > also.. > > Still it's not working.. > > Can anybody help me out.. > > > Thanks > > Regards, > Sheetal > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- ;-) Jorge Martin Cuervo Analista Programador Outsourcing Emarketplace deFacto Powered by Standards email <[EMAIL PROTECTED]> voz +34 985 129 820 voz +34 660 026 384
Validator FRamework
Hi All, I had problem.. I am trying to implement client side validation using Validator FRamework. I have added validator-rules.xml, and validation.xml, in my web -inf file. And made following entry in validation.xml i have also added added an entry in struts config.xml. type="com.hns.nme.frontend.apps.cmdexecution.form.SelectCommandForm" /> type="com.hns.nme.frontend.apps.cmdexecution.form.RunCommandForm" /> type="com.hns.nme.frontend.apps.cmdexecution.action.SelectCommandAction" scope="request"> type="com.hns.nme.frontend.apps.cmdexecution.action.RunCommandAction" input="/JSP/RunCommand.jsp" attribute="runCommandForm" name="runCommandForm" scope="request"> parameter="com.hns.nme.frontend.apps.cmdexecution.ApplicationResources" /> value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> Extended my form class from ValidatorActionForm. AND iN JSP PAGE i HAVE ADDED also.. Still it's not working.. Can anybody help me out.. Thanks Regards, Sheetal - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator and DynaValidatorActionForm
Thanks a lot for all that feedback. I think it gets me a step further. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator and DynaValidatorActionForm
On 8/30/06, Tom Bednarz <[EMAIL PROTECTED]> wrote: What is the correct or preferred way to link business-objects with form beans. Is this only possible by copying data from a business object to a form bean or is there any 'smarter' way? You might want to take a look at FormDef: https://formdef.dev.java.net/ -- Wendy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator and DynaValidatorActionForm
Tom Bednarz wrote: So I used Don't specify value. Simply copy the properties from a subscriber object (session scoped or otherwise) to a formbean (the one being used to render the form values). There's a copyProperties method in org.apache.commons.beanutils.BeanUtils: http://tinyurl.com/zp6ag Also, the Spring Framework has a copyProperties method in one of its utility classes. It has the advantage of not throwing a checked exception and its parameter ordering makes more sense to some (myself included). A reason to not specify a value for html:text, at the view level, is that it overwrites the value in an associated form-bean object. This could lead to overwriting user input or overwriting data that was populated from an Action. It may be acceptable to specify value on a checkbox, for instance, because user's don't typically interact with this value directly. Still, if a value for a checkbox, like any other form control, was set in a controller class, then a page level value will overwrite data. At the very least, this is counterintuitive. More often, it is incorrect. -Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator and DynaValidatorActionForm
Thanks a lot for all your input and help. It looks like I need some basic concepts clarified. Here a very short background of the application and what my intension is: The object 'subscriber' is a special business object: it represents the logged in user and contains a lot of information about him: Personal data like name, address, e-mail, preferred language etc. But it contains also information about his roles, type of subsciption he bought etc. Shortly I need parts of this information almost everywhere in the application and thats why the thing sits in session scope. The action we were discussing 'changePersonalDataForm' represents a form where the user can change some of this informations such as personal data, language etc. Other things such as roles, subscibtion information etc are not visible to the user. The object has logic to retrieve its information from various database tables and also store information back if there are changes. This is performed exclusively in this object not in any action. The object is created and filled when the user has successfully logged in. So I used to initially fill the firstname directly from the business object into the form. If the user submits the form the information is updated in the object and also written back to the DB server. Nice things like ChangeEventListeners as available in Swing and also in JSF are sort of missing in Struts (at least I did not find something alike) So the key question seems to be: What is the correct or preferred way to link business-objects with form beans. Is this only possible by copying data from a business object to a form bean or is there any 'smarter' way? Copying ends up in writing a lot of copy-code which is inefficient. I am looking for sort of a component model, which means I have a couple of objects in session or even application scope and can directly use then in many different forms/actions. But so far I am missing a concept like SWING controls do have it where you can bind controls such as a listbox, textbox etc directly to objects or even database tables. I think JSF offers similar things but I don't see anything alike in struts 1.2.8 (the version I am currently using). Maybe someone could clarify these things for me or you may have some good recipes for me, how to solve these things best with Struts. Many thanks again for your help! Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator and DynaValidatorActionForm
Tom Bednarz wrote: David Durham wrote: Tom Bednarz wrote: I think the validator fires too early, but probably I am doing something wrong. Maybe somebody can hp! Basically, you need 2 actions, one to populate the form and one to change the personal data. Or at least two action mappings, if you want to use automatic validation. If you're happy to invoke validation manually, you can get by with just one action and one mapping. This is EXACTLY what I like to AVOID! With this concept I have to write dozends of useless action classes! Nope, with that approach you would simply *seperate* your one action class into two classes which each encapsulate one branch or your if statement below -- i.e. an action that does 'Populate the form' and one that does 'Perform update operation'. If you don't like having two separate classes, there are various options for combining them, including the various flavours of dispatch action and the approach you illustrate below. In my Action class I did: public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ActionForward af = null; .. String operation = request.getParameter("operation"); . if (operation != null && operation.compareToIgnoreCase("update") == 0) { . Perform update operation here } else // showData { Populate form here } return (new ActionForward("/showPersonalData.do")); } The surprising thing (at least for me...) is, that when running in the debugger, execute method is NEVER called (does not stop at any breakpoint) !!! Do you have validate="true" on your action mapping? If validate is set to true, the framework will perform validation for you automatically before invoking the action. Hence, you need to either a) have two action mappings in your config (note: two mappings, not necessarily two action classes), one with validate=false and operation set to null and one with validate=true and operation set to whatever; or b) using a single action mapping, set validate=false and call validate() manually as appropriate. Is there no more intelligent way then creating lots of actions?? Maybe this is a motivation to move to JSF!! L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator and DynaValidatorActionForm
On 8/30/06, Tom Bednarz <[EMAIL PROTECTED]> wrote: The idea is, that I show a form that contains already data and the user can edit it. When the form is submitted, the validator should check the user input. Here is my validator configuration: ... Now it seems, that the validator gets fired BEFORE the form is filled! In the JSP that displays the form, I get lots of error messages all fired by the 'required' validator saying, that the field must not be empty, but all fields are filled corretly!!. Request -> form bean population -> validation -> Action.execute() -> forward -> JSP My advice is to turn off automatic validation, and call it explicitly when you want it to happen. That will stop the 'validation errors on first form display' problem. Looking at your config, you always pull values from a session scoped 'subscriber' object. I don't think you need 'value' here: The 'name' attribute [1] is "The attribute name of the bean whose properties are consulted when rendering the current value of this input field." Does this work? Even after dealing with the 'first display' problem, that still leaves you validating the form bean (which may be missing data) yet displaying values from some other bean sitting in session scope. [1] http://struts.apache.org/1.x/struts-taglib/tlddoc/html/text.html -- Wendy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validator and DynaValidatorActionForm
Why are you making these fields so complex? You have Instead of the simple form: ? Why do you need to specify all of that redundant information like value and name when you have the property attribute? And why are you pulling values from the session scope instead of the request data that was submitted? That seems an unusual choice to my thinking. Also, what is your html:form action specified there? Is it listed as "/changePersonalDataForm"? Or another form name? Using a different form might be your problem - after all the html:form uses the bean associated with that form so a different bean would have different values, especially if you are mixing and matching values from a session scoped bean with a request that has its own values. Regards, David -Original Message- From: Tom Bednarz [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 12:34 PM To: Struts Users Mailing List Subject: validator and DynaValidatorActionForm I think the validator fires too early, but probably I am doing something wrong. Maybe somebody can hp! I have the following form bean defined in struts-config.xml: and the following action mapping: The idea is, that I show a form that contains already data and the user can edit it. When the form is submitted, the validator should check the user input. Here is my validator configuration: Now it seems, that the validator gets fired BEFORE the form is filled! In the JSP that displays the form, I get lots of error messages all fired by the 'required' validator saying, that the field must not be empty, but all fields are filled corretly!!. Here is an extract of the JSP: ... Every row contains a label, an input control and a TD to display validation errors of the specific field. Does anybody know what is going wrong here?? Many thanks for your help! Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator and DynaValidatorActionForm
David Durham wrote: Tom Bednarz wrote: I think the validator fires too early, but probably I am doing something wrong. Maybe somebody can hp! Basically, you need 2 actions, one to populate the form and one to change the personal data. David, This is EXACTLY what I like to AVOID! With this concept I have to write dozends of useless action classes! In my Action class I did: public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ActionForward af = null; .. String operation = request.getParameter("operation"); . if (operation != null && operation.compareToIgnoreCase("update") == 0) { . Perform update operation here } else // showData { Populate form here } return (new ActionForward("/showPersonalData.do")); } The surprising thing (at least for me...) is, that when running in the debugger, execute method is NEVER called (does not stop at any breakpoint) !!! Is there no more intelligent way then creating lots of actions?? Maybe this is a motivation to move to JSF!! Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validator and DynaValidatorActionForm
Tom Bednarz wrote: I think the validator fires too early, but probably I am doing something wrong. Maybe somebody can hp! Basically, you need 2 actions, one to populate the form and one to change the personal data. I have the following form bean defined in struts-config.xml: type="org.apache.struts.validator.DynaValidatorActionForm" > and the following action mapping: The idea is, that I show a form that contains already data and the user can edit it. When the form is submitted, the validator should check the user input. Here is my validator configuration: Now it seems, that the validator gets fired BEFORE the form is filled! In the JSP that displays the form, I get lots of error messages all fired by the 'required' validator saying, that the field must not be empty, but all fields are filled corretly!!. Here is an extract of the JSP: ... Every row contains a label, an input control and a TD to display validation errors of the specific field. Does anybody know what is going wrong here?? Many thanks for your help! Tom - 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]
validator and DynaValidatorActionForm
I think the validator fires too early, but probably I am doing something wrong. Maybe somebody can hp! I have the following form bean defined in struts-config.xml: type="org.apache.struts.validator.DynaValidatorActionForm" > and the following action mapping: The idea is, that I show a form that contains already data and the user can edit it. When the form is submitted, the validator should check the user input. Here is my validator configuration: Now it seems, that the validator gets fired BEFORE the form is filled! In the JSP that displays the form, I get lots of error messages all fired by the 'required' validator saying, that the field must not be empty, but all fields are filled corretly!!. Here is an extract of the JSP: ... Every row contains a label, an input control and a TD to display validation errors of the specific field. Does anybody know what is going wrong here?? Many thanks for your help! Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regarding Struts validator Framework
In the jsp code u givenonsubmit="return validateCustomerForm(this); but in validator-user.xml the form name is custForm, so replace that with onsubmit="return validateCustForm(this); Thanks, Srinivas. Lakshmi Saritha <[EMAIL PROTECTED] m> To user@struts.apache.org 08/30/2006 10:05 cc AM Subject Regarding Struts validator Please respond to Framework "Struts Users Mailing List" <[EMAIL PROTECTED] he.org> Hello everybody, I'm new to Java. I'm working on Struts now. I got this application from one struts PDF. I've one jsp for customer details as follows: CustomerDetails.jsp: <%@ page contentType="text/html;charset=UTF-8" language="java"%> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> CustomerForm.java: import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.ValidatorForm; import javax.servlet.http.HttpServletRequest; public class CustomerForm extends ValidatorForm { private String firstName; private String lastName; public CustomerForm(){ firstName=""; lastName=""; } public String getFirstName(){ return firstName; } public void setFirstName(String fn){ this.firstName=fn; } public String getLastName(){ return lastName; } public void setLastName(String ln){ this.lastName=ln; } } CustomerAction.java: import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMessages; import org.apache.struts.action.ActionMessage; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class CustomerAction extends Action { public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{ if(isCancelled(request)){ System.out.println("Cancel Operation Performed"); return mapping.findForward("mainpage"); } CustomerForm custForm=(CustomerForm) form; String firstName=custForm.getFirstName(); String lastName=custForm.getLastName(); System.out.println("Customer First name is "+firstName); System.out.println("Custoemr Last name is "+lastName); ActionForward forward=mapping.findForward("success"); return forward; } } web.xml f http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4" xmlns=" http://java.sun.com/xml/ns/j2ee";> Empty web.xml file for Web Application action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml debug 3 application /WEB-INF/classes/App1Messages.properties detail 3 validate true 1 action *.do 35 html text/html txt text/plain index.jsp /WEB-INF/struts-bean.tld /WEB-INF/struts-bean.tld /WEB-INF/struts-html.tld /WEB-INF/struts-html.tld /WEB-INF/struts-logic.tld /WEB-INF/struts-logic.tld struts-config.xml http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";> Upto now it's working fine. But it&
Re: Regarding Struts validator Framework
On 8/29/06, Lakshmi Saritha <[EMAIL PROTECTED]> wrote: Please clear me why the message is not coming from properties file. Is the error in properties file or validator-rules.xml or some other. Try adding an tag to your CustomerDetails JSP, I don't see it there. -- Wendy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Regarding Struts validator Framework
Hello everybody, I'm new to Java. I'm working on Struts now. I got this application from one struts PDF. I've one jsp for customer details as follows: CustomerDetails.jsp: <%@ page contentType="text/html;charset=UTF-8" language="java"%> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> CustomerForm.java: import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.ValidatorForm; import javax.servlet.http.HttpServletRequest; public class CustomerForm extends ValidatorForm { private String firstName; private String lastName; public CustomerForm(){ firstName=""; lastName=""; } public String getFirstName(){ return firstName; } public void setFirstName(String fn){ this.firstName=fn; } public String getLastName(){ return lastName; } public void setLastName(String ln){ this.lastName=ln; } } CustomerAction.java: import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMessages; import org.apache.struts.action.ActionMessage; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class CustomerAction extends Action { public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{ if(isCancelled(request)){ System.out.println("Cancel Operation Performed"); return mapping.findForward("mainpage"); } CustomerForm custForm=(CustomerForm) form; String firstName=custForm.getFirstName(); String lastName=custForm.getLastName(); System.out.println("Customer First name is "+firstName); System.out.println("Custoemr Last name is "+lastName); ActionForward forward=mapping.findForward("success"); return forward; } } web.xml f http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee";> Empty web.xml file for Web Application action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml debug 3 application /WEB-INF/classes/App1Messages.properties detail 3 validate true 1 action *.do 35 html text/html txt text/plain index.jsp /WEB-INF/struts-bean.tld /WEB-INF/struts-bean.tld /WEB-INF/struts-html.tld /WEB-INF/struts-html.tld /WEB-INF/struts-logic.tld /WEB-INF/struts-logic.tld struts-config.xml http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";> Upto now it's working fine. But it's not displaying the error message that I've mentioned in the properties file. This file is as follows and is in WEB-INF/classes. App1Messages.properties: custForm.firstName=First Name custForm.lastName=Last Name errors.required=Required validator-rules.xml http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd";> . . . validator.xml http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd";> I've my success.jsp and failure.jsp. When I don't enter data into firstname and lastname, the form is displayed, but the error message is not displying. validator.xml is working fine because if I don't give any one or both of first name and last name it's displaying the empty form and if I give both, success.jsp is displaying. In some struts pdfs I've seen that if validation errors occur, the JSP u menthioned in input attribute is displayed with the errors taken from properties file. Is is true or not? If so, why did the author used the Failure.jsp again? Please clear me why the message is not coming from properties file. Is the error in properties file or validator-rules.xml or some other. Thanks and regards, Saritha - Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
validator needed jar files.
Hi, I'm deploying a struts application with a weblogic server.. It seems to work fine, but I've got problems with validator and html:javascript tag. That tag does not work, maybe because a jar file is missing.. but I don't know which one. I've developped my app with Tomcat, and it works well.. I maybe did a mistake building my app.. But I just can't find which file is missing!!! does someone kwow the exhaustiv file list to have to use validator plugin ? thx -- View this message in context: http://www.nabble.com/validator-needed-jar-files.-tf2177219.html#a6019802 Sent from the Struts - User forum at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts 1.2 and the Validator Framework, how does this work ? continue
thanks for the reply. I am not yet used to this mailing list, sorry for that, I probably could have continued this question in the same thread - but not knowing how to do that. Niall you are probably right, that I should upgrade. Using Exadel and it's support for Struts, it only says struts 1.2 so I do not know if it is struts 1.2.4 or 1.2.7 or something else - reading on the subject now - so I would not know which upgrade to use and where to install that in the eclipse or exadel file-structure Do you have any advice on that ? this is what my log4j says: 1. 15:13:14,859 ERROR ValidatorForm:112 - org.apache.struts.validator.FieldChecks.validateMinLength( java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest) org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateMinLength( java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest) at org.apache.commons.validator.ValidatorAction.loadValidationMethod( ValidatorAction.java:627) at org.apache.commons.validator.ValidatorAction.executeValidationMethod( ValidatorAction.java:557) at org.apache.commons.validator.Field.validateForRule(Field.java :827) at org.apache.commons.validator.Field.validate(Field.java:906) at org.apache.commons.validator.Form.validate(Form.java:174) at org.apache.commons.validator.Validator.validate(Validator.java :367) at org.apache.struts.validator.ValidatorForm.validate( ValidatorForm.java:110) at se.svemab.struts.form.InputForm.validate(InputForm.java:30) at org.apache.struts.action.RequestProcessor.processValidate( RequestProcessor.java:950) at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:207) at org.apache.struts.action.ActionServlet.process( ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost( ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter( ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke( StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke( StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke( ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke( StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service( CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process( Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection (Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket( PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt( LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run( ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) regards, i
RE: Struts 1.2 and the Validator Framework, how does this work ?
I think your Configuration Struts+Validator may be giving problem. -Original Message- From: Li [mailto:[EMAIL PROTECTED] Sent: Friday, August 25, 2006 1:02 PM To: Struts Users Mailing List Subject: Re: Struts 1.2 and the Validator Framework, how does this work ? did you configure your app and validation framework properly? can you paste full stack of error? On 8/25/06, Ingimar Erlingsson <[EMAIL PROTECTED]> wrote: > > Hello! > > trying to get the validator framework in struts to work from within > eclipse/exadel, using struts 1.2. > following an example in the book 'professional jakarta struts' from WROX , > that is chapter 12, but always getting errors like the following. The > example is a simple form, submitting a name. > > could anyone tell me what is wrong ? > here is the error ( a part ): > 006-08-23 23:00:30,515 ERROR [org.apache.struts.validator.ValidatorForm] - > org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, > org.apache.commons.validator.ValidatorAction, > org.apache.commons.validator.Field, > org.apache.struts.action.ActionMessages, > javax.servlet.http.HttpServletRequest ) > org.apache.commons.validator.ValidatorException: > org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, > org.apache.commons.validator.ValidatorAction, > org.apache.commons.validator.Field, > org.apache.struts.action.ActionMessages, > javax.servlet.http.HttpServletRequest) >at org.apache.commons.validator.ValidatorAction.loadValidationMethod( > ValidatorAction.java:627) >at org.apache.commons.validator.ValidatorAction.executeValidationMethod( > ValidatorAction.java:557) > > -- When we invent time, we invent death. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1.2 and the Validator Framework, how does this work ?
Usually this error occurs when people upgrade to a later version of Struts, but forget to upgrade the validator-rules.xml to the one shipped with the new Struts version. http://wiki.apache.org/struts/StrutsUpgrade Niall On 8/25/06, Ingimar Erlingsson <[EMAIL PROTECTED]> wrote: Hello! trying to get the validator framework in struts to work from within eclipse/exadel, using struts 1.2. following an example in the book 'professional jakarta struts' from WROX , that is chapter 12, but always getting errors like the following. The example is a simple form, submitting a name. could anyone tell me what is wrong ? here is the error ( a part ): 006-08-23 23:00:30,515 ERROR [org.apache.struts.validator.ValidatorForm] - org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest ) org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest) at org.apache.commons.validator.ValidatorAction.loadValidationMethod( ValidatorAction.java:627) at org.apache.commons.validator.ValidatorAction.executeValidationMethod ( ValidatorAction.java:557) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1.2 and the Validator Framework, how does this work ?
did you configure your app and validation framework properly? can you paste full stack of error? On 8/25/06, Ingimar Erlingsson <[EMAIL PROTECTED]> wrote: Hello! trying to get the validator framework in struts to work from within eclipse/exadel, using struts 1.2. following an example in the book 'professional jakarta struts' from WROX , that is chapter 12, but always getting errors like the following. The example is a simple form, submitting a name. could anyone tell me what is wrong ? here is the error ( a part ): 006-08-23 23:00:30,515 ERROR [org.apache.struts.validator.ValidatorForm] - org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest ) org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest) at org.apache.commons.validator.ValidatorAction.loadValidationMethod( ValidatorAction.java:627) at org.apache.commons.validator.ValidatorAction.executeValidationMethod( ValidatorAction.java:557) -- When we invent time, we invent death.
Struts 1.2 and the Validator Framework, how does this work ?
Hello! trying to get the validator framework in struts to work from within eclipse/exadel, using struts 1.2. following an example in the book 'professional jakarta struts' from WROX , that is chapter 12, but always getting errors like the following. The example is a simple form, submitting a name. could anyone tell me what is wrong ? here is the error ( a part ): 006-08-23 23:00:30,515 ERROR [org.apache.struts.validator.ValidatorForm] - org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest ) org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest) at org.apache.commons.validator.ValidatorAction.loadValidationMethod( ValidatorAction.java:627) at org.apache.commons.validator.ValidatorAction.executeValidationMethod ( ValidatorAction.java:557)
Re: Validator html args
Theres no way of picking up what was rendered in your view in the validation config. If you're "hard coding" your label values rather than putting them in the message resources though, you can do the same in your validation.xml - using the resource="false" attribute. ... or even the whole error message. Niall On 8/22/06, Jean-Marie Pitre <[EMAIL PROTECTED]> wrote: Hi, I am using Validator 1.3, I would like to know if I can pass argument value issued from html element? I explain me: I have an html form : ... User ... My validation looks like this: Do you know if there a mean to display the labeluser (font id) instead of putting value in a resource bundle? Thanks, Regards, Jean-Marie. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validator html args
Hi, I am using Validator 1.3, I would like to know if I can pass argument value issued from html element? I explain me: I have an html form : ... User ... My validation looks like this: Do you know if there a mean to display the labeluser (font id) instead of putting value in a resource bundle? Thanks, Regards, Jean-Marie. --- Email Disclaimer http://www.cofidis.be/emaildisclaimer.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I can't put 'maxlength' validator values in my .properties file?
On 8/16/06, Scott Van Wart <[EMAIL PROTECTED]> wrote: I tried the following: Now I figured that this would cause the maxlength validator to get the value for maxlength from message resources, rather than hardcoding it with var, var-name and var-value tags. But it doesn't! It only uses this to pass to the {0} in the error message (in org.apache.struts.validator.FieldChecks.validateMaxLength, version 1.1.4): // No reference to resources at this point, only in the exception handler int max = Integer.parseInt(field.getVarValue("maxlength")); Am I missing something? Yes - two things: 1) The maxlength validator never gets the "variable" values used to validate from elements - they are only ever used for "error message arguments". So you need to specify a element to specify the maxlength value. 2) Support for "variables" being specified in "resources" was added to Struts 1.3.x (and not the 1.2.x branch) - so even if you upgraded to Validator 1.2.0 or Validator 1.3.0 its not going to work with Strutsb 1.2.x - try Struts 1.3.5 http://wiki.apache.org/jakarta-commons/ValidatorVersion120 Niall - Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator Client-Side and Custom Classes
Mississippi John Hurt wrote: Hi, I want to do client-side validation using a custom class I can specify in the validator.xml section. But my question is if I use a custom class, then how the heck can Struts generate the custom javascript for it in the jsp if I'm using a custom java class I wrote that exists only on the server? Not possible right? So if that's the case, if you do leave some custom classname validator class in your validation.xml, then will that validation simply be ignored? Thanks for help with these 2 questions. If you look at the source for commons-validator, you'll see a package called 'org.apache.commons.validator.javascript'. It has a bunch of .js files as package resources, so you might look at the sources for those to get started. Beyond that I don't have any experience with it (I personally can't stand client-side validations, as validation has to be done in the database, and on the server side, and I feel inclined to draw the line somewhere given a choice :). The 'validateUtilities.js' seems to have a lot of functions that the other .js files make use of, so you should probably do so as well. It also looks like the .js file name, and function name inside the file match the method name of your validation routine (with a 'form' parameter passed, which is likely an array?). So if you do all this, I would imagine the validator will pick it up automatically (and fail silently and ignore it if you don't, as you mentioned above). Good luck, Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I can't put 'maxlength' validator values in my .properties file?
David Friedman wrote: Right, but the invoked Resources.getActionMessage() has calls inside it for the bundle in the current trunk: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apa che/struts/validator/Resources.java?view=markup It looks like it hasn't changed from the 1.2.X branch and it is definitely different compared to the 1.1.X branch. If you correct the problem to the Resources class you might want to submit it to JIRA. http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/FieldChecks.java?revision=289694&view=markup This is the first revision with the resource support (2005 Sep 17). Struts 1.2.9 was released 2006 Mar 22, but doesn't include this! - Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I can't put 'maxlength' validator values in my .properties file?
David Friedman wrote: Right, but the invoked Resources.getActionMessage() has calls inside it for the bundle in the current trunk: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apa che/struts/validator/Resources.java?view=markup It looks like it hasn't changed from the 1.2.X branch and it is definitely different compared to the 1.1.X branch. If you correct the problem to the Resources class you might want to submit it to JIRA. Geesh that's weird... I'm glad you sent the link to the trunk. FieldChecks specifically is what is causing me problems. getVarValue is called indistriminately in my copy of struts (1.2.9 to the very, very best of my knowledge), but according to http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/FieldChecks.java?view=markup, the trunk's validateMaxLength is completely different... sigh... time to check some more JARs. Actually, I'm going to check the 1.2.x branch first to see whether or not I'm completely off my rocker. In between your posts I wrote my own validateMaxLength that does the same thing (only not as generically(sp) as the trunk's version). You should really type your posts faster (kidding! :) Thanks again! - Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: I can't put 'maxlength' validator values in my .properties file?
Right, but the invoked Resources.getActionMessage() has calls inside it for the bundle in the current trunk: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apa che/struts/validator/Resources.java?view=markup It looks like it hasn't changed from the 1.2.X branch and it is definitely different compared to the 1.1.X branch. If you correct the problem to the Resources class you might want to submit it to JIRA. Regards, David -Original Message- From: Scott Van Wart [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 16, 2006 1:30 PM To: Struts Users Mailing List Subject: Re: I can't put 'maxlength' validator values in my .properties file? David Friedman wrote: > I think you need to have at least Struts v1.2.8 unless you manually upgraded > the Commons Validator jar up to version 1.2.0. If I understand correctly, > validator versions before 1.2.0 (Struts < 1.2.8) don't actually make use of > the "bundle" attribute in your validator xml files. > > So, what version of Struts are you using (1.1.4?) and/or what version of the > Commons Validator are you using? Have you tried replacing the commons > validator jar? I think I read that some people have tried that for older > versions but I'm not positive. > Another issue is that the FieldChecks class is a part of Struts (1.2.9) and not the commons validator. The line where I would assume it should grab it from the resources bundle doesn't contain any resource references: /** * Checks if the field's length is less than or equal to the maximum value. * A Null will be considered an error. * * @param bean The bean validation is being performed on. * @param va The ValidatorAction that is currently being performed. * @param fieldThe Field object associated with the current * field being validated. * @param errors The ActionMessages object to add errors to if any * validation errors occur. * @param validator The Validator instance, used to access * other field values. * @param request Current request object. * @return True if stated conditions met. */ public static boolean validateMaxLength(Object bean, ValidatorAction va, Field field, ActionMessages errors, Validator validator, HttpServletRequest request) { String value = null; if (isString(bean)) { value = (String) bean; } else { value = ValidatorUtils.getValueAsString(bean, field.getProperty()); } if (value != null) { try { int max = Integer.parseInt(field.getVarValue("maxlength")); // < RIGHT HERE if (!GenericValidator.maxLength(value, max)) { errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field)); return false; } } catch (Exception e) { errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field)); return false; } } return true; } So it's looking like I'm going to need to write my own validator. OH well - Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I can't put 'maxlength' validator values in my .properties file?
David Friedman wrote: I think you need to have at least Struts v1.2.8 unless you manually upgraded the Commons Validator jar up to version 1.2.0. If I understand correctly, validator versions before 1.2.0 (Struts < 1.2.8) don't actually make use of the "bundle" attribute in your validator xml files. So, what version of Struts are you using (1.1.4?) and/or what version of the Commons Validator are you using? Have you tried replacing the commons validator jar? I think I read that some people have tried that for older versions but I'm not positive. Another issue is that the FieldChecks class is a part of Struts (1.2.9) and not the commons validator. The line where I would assume it should grab it from the resources bundle doesn't contain any resource references: /** * Checks if the field's length is less than or equal to the maximum value. * A Null will be considered an error. * * @param bean The bean validation is being performed on. * @param va The ValidatorAction that is currently being performed. * @param fieldThe Field object associated with the current * field being validated. * @param errors The ActionMessages object to add errors to if any * validation errors occur. * @param validator The Validator instance, used to access * other field values. * @param request Current request object. * @return True if stated conditions met. */ public static boolean validateMaxLength(Object bean, ValidatorAction va, Field field, ActionMessages errors, Validator validator, HttpServletRequest request) { String value = null; if (isString(bean)) { value = (String) bean; } else { value = ValidatorUtils.getValueAsString(bean, field.getProperty()); } if (value != null) { try { int max = Integer.parseInt(field.getVarValue("maxlength")); // < RIGHT HERE if (!GenericValidator.maxLength(value, max)) { errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field)); return false; } } catch (Exception e) { errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field)); return false; } } return true; } So it's looking like I'm going to need to write my own validator. OH well - Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I can't put 'maxlength' validator values in my .properties file?
David Friedman wrote: I think you need to have at least Struts v1.2.8 unless you manually upgraded the Commons Validator jar up to version 1.2.0. If I understand correctly, validator versions before 1.2.0 (Struts < 1.2.8) don't actually make use of the "bundle" attribute in your validator xml files. So, what version of Struts are you using (1.1.4?) and/or what version of the Commons Validator are you using? Have you tried replacing the commons validator jar? I think I read that some people have tried that for older versions but I'm not positive. Validator 1.1.4 (according to the manifest, and Eclipse seems to think the source syncs up properly so I'm convinced), the one that came with Struts 1.2.9 (which I'm using too). I'll try updating the validator, thanks! - Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: I can't put 'maxlength' validator values in my .properties file?
I think you need to have at least Struts v1.2.8 unless you manually upgraded the Commons Validator jar up to version 1.2.0. If I understand correctly, validator versions before 1.2.0 (Struts < 1.2.8) don't actually make use of the "bundle" attribute in your validator xml files. So, what version of Struts are you using (1.1.4?) and/or what version of the Commons Validator are you using? Have you tried replacing the commons validator jar? I think I read that some people have tried that for older versions but I'm not positive. Regards, David -Original Message- From: Scott Van Wart [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 16, 2006 1:04 PM To: user@struts.apache.org Subject: I can't put 'maxlength' validator values in my .properties file? I tried the following: Now I figured that this would cause the maxlength validator to get the value for maxlength from message resources, rather than hardcoding it with var, var-name and var-value tags. But it doesn't! It only uses this to pass to the {0} in the error message (in org.apache.struts.validator.FieldChecks.validateMaxLength, version 1.1.4): // No reference to resources at this point, only in the exception handler int max = Integer.parseInt(field.getVarValue("maxlength")); Am I missing something? - Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
I can't put 'maxlength' validator values in my .properties file?
I tried the following: Now I figured that this would cause the maxlength validator to get the value for maxlength from message resources, rather than hardcoding it with var, var-name and var-value tags. But it doesn't! It only uses this to pass to the {0} in the error message (in org.apache.struts.validator.FieldChecks.validateMaxLength, version 1.1.4): // No reference to resources at this point, only in the exception handler int max = Integer.parseInt(field.getVarValue("maxlength")); Am I missing something? - Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validator Client-Side and Custom Classes
Hi, I want to do client-side validation using a custom class I can specify in the validator.xml section. But my question is if I use a custom class, then how the heck can Struts generate the custom javascript for it in the jsp if I'm using a custom java class I wrote that exists only on the server? Not possible right? So if that's the case, if you do leave some custom classname validator class in your validation.xml, then will that validation simply be ignored? Thanks for help with these 2 questions.
Re: Validator
From Struts 1.2.7 onwards you can change the keys used with the "header", "footer", "prefix" and "suffix" attributes http://struts.apache.org/1.2.9/userGuide/struts-html.html#errors Niall On 8/11/06, Kalra, Ashwani <[EMAIL PROTECTED]> wrote: They are hard coded in mailto:[EMAIL PROTECTED] Sent: Friday, August 11, 2006 2:58 PM To: Struts Users Mailing List Subject: Validator Hi, I would like to change the key name of errors.header, errors.footer, errors.suffix ... but I don't see where they are called. Have you got any idea ? Thanks, Jean-Marie. --- Email Disclaimer http://www.cofidis.be/emaildisclaimer.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. - 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
On 8/11/06, Kalra, Ashwani <[EMAIL PROTECTED]> wrote: They are hard coded in It's not a configurable property, but, if it's an issue for someone, just plug in your own version of the errors tag. -Ted. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator
Don't think you really understand the issue, Simian. On 8/11/06, Monkeyden <[EMAIL PROTECTED]> wrote: Who cares where they're called or what their values are? Just add them to the application resources file. On 8/11/06, Jean-Marie Pitre <[EMAIL PROTECTED]> wrote: > > > Hi, > > I would like to change the key name of errors.header, errors.footer, > errors.suffix ... but I don't see where they are called. > > Have you got any idea ? > > Thanks, > > Jean-Marie. > > --- > Email Disclaimer > http://www.cofidis.be/emaildisclaimer.php > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- "You can lead a horse to water but you cannot make it float on its back." ~Dakota Jack~
Re: Validator
Who cares where they're called or what their values are? Just add them to the application resources file. On 8/11/06, Jean-Marie Pitre <[EMAIL PROTECTED]> wrote: Hi, I would like to change the key name of errors.header, errors.footer, errors.suffix ... but I don't see where they are called. Have you got any idea ? Thanks, Jean-Marie. --- Email Disclaimer http://www.cofidis.be/emaildisclaimer.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator
They are hard coded in mailto:[EMAIL PROTECTED] Sent: Friday, August 11, 2006 2:58 PM To: Struts Users Mailing List Subject: Validator Hi, I would like to change the key name of errors.header, errors.footer, errors.suffix ... but I don't see where they are called. Have you got any idea ? Thanks, Jean-Marie. --- Email Disclaimer http://www.cofidis.be/emaildisclaimer.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validator
Hi, I would like to change the key name of errors.header, errors.footer, errors.suffix ... but I don't see where they are called. Have you got any idea ? Thanks, Jean-Marie. --- Email Disclaimer http://www.cofidis.be/emaildisclaimer.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RE : Validator dynamic var
You could implement your own MessageResources which could call a java class instead of a properties file. You would need to do something like the following: 1) Create your own MessageResources implementation: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/util/MessageResources.java?view=markup public class VarMessageResources extends MessageResources { public String getMessage(Locale locale, String key) { // call your java class here } } 2) Create a MessageResourcesFactory public class VarMessageResourcesFactory extends MessageResourcesFactory { public MessageResources createResources(String config) { return new VarMessageResources(this, config, this.returnNull); } } 3) Configure Struts for your custom MessageResources (using a "bundle" key) 4) Reference your custom message resources in the validation.xml datePattern dateOfBirth.pattern Niall On 8/7/06, Jean-Marie Pitre <[EMAIL PROTECTED]> wrote: Thank you Niall, Do you know if I can call a java class instead of a properties file ? Jean-Marie. -Message d'origine- De: Niall Pemberton [mailto:[EMAIL PROTECTED] Envoyé: lundi 7 août 2006 15:37 À: Struts Users Mailing List Objet: Re: Validator dynamic var You can do this in Struts 1.3.x and Commons Validator 1.3.0 where the element can come from a resource bundle. See the "1.2 Variables in Resource Bundles" section here: http://wiki.apache.org/jakarta-commons/ValidatorVersion120 Niall On 8/7/06, Jean-Marie Pitre <[EMAIL PROTECTED]> wrote: > > Hi, > > Is it possible to set dynamic variable value in validation.xml file ? > > My application is in several language and I would like avoid to define > several formset definition according to each language to just change > datepatternstrict value. > > Any idea ? > > Thanks, > Regards Jean-Marie. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Email Disclaimer http://www.cofidis.be/emaildisclaimer.php - 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 dynamic var
Thank you Niall, Do you know if I can call a java class instead of a properties file ? Jean-Marie. -Message d'origine- De : Niall Pemberton [mailto:[EMAIL PROTECTED] Envoyé : lundi 7 août 2006 15:37 À : Struts Users Mailing List Objet : Re: Validator dynamic var You can do this in Struts 1.3.x and Commons Validator 1.3.0 where the element can come from a resource bundle. See the "1.2 Variables in Resource Bundles" section here: http://wiki.apache.org/jakarta-commons/ValidatorVersion120 Niall On 8/7/06, Jean-Marie Pitre <[EMAIL PROTECTED]> wrote: > > Hi, > > Is it possible to set dynamic variable value in validation.xml file ? > > My application is in several language and I would like avoid to define > several formset definition according to each language to just change > datepatternstrict value. > > Any idea ? > > Thanks, > Regards Jean-Marie. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Email Disclaimer http://www.cofidis.be/emaildisclaimer.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator not getting called and I can't see why [resolved]
I had a similar problem here. I used formdef to define the page attribute and didn't specify the type. When the cast was made inside of validator, it was unable to cast the value to an Integer. The field was a string containing the page number. Couldn't it use Integer.valueOf? -Original Message- From: Bart Busschots [mailto:[EMAIL PROTECTED] Sent: Sunday, August 06, 2006 3:33 PM To: Struts Users Mailing List Subject: Re: Validator not getting called and I can't see why [resolved] OK, I got all this figured out in the end. The validator was being called but because of problems with the page attribute in the form the validator appears to have been receiving a page value of zero and hence not validating the items on pages 1 or two because neither 1 nor 2 are less that or equal to zero! When I did get the validator to be called it still wasn't working right but I got that fixed too. Anyhow, I did up a blog post about it which can be found here: http://www.bartbusschots.ie/blog/?p=262 If people thing an edited version of this would be a useful addition to the Wiki work away, just credit me or link to the original blog post and I'll be more than happy. Cheers for your help guys, Bart. Bart Busschots wrote: > I'm either missing something stupid (which is always possible) or I've > managed to break the validator. I have an app that uses validator all > over the place and it's working fine in all my other actions but for > this one action it is simply not getting called. > > I can't see any difference between this action/form/validation and all > the other ones that are working. > > This is the form: > > type="org.apache.struts.validator.DynaValidatorForm"> > > > > > > > > This is the action: > > type="vtie.portal.mentor.CreateStudentGroupPrepareAction" > name="createStudentGroupForm" scope="session" validate="true" > input="/home/mentor/addStudentGroupForm.jsp"> >path="/do/mentor/createAnonymousStudentGroup" /> >path="/home/mentor/getStudentNamesForm.jsp" /> > > > > And this is the validation: > > > >mask^[a-zA-Z]+[\w\ > ]*$ > > > > > > > > > > > Can anyone see something obviously wrong there? > > Cheers, > > Bart. > > - > 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 dynamic var
You can do this in Struts 1.3.x and Commons Validator 1.3.0 where the element can come from a resource bundle. See the "1.2 Variables in Resource Bundles" section here: http://wiki.apache.org/jakarta-commons/ValidatorVersion120 Niall On 8/7/06, Jean-Marie Pitre <[EMAIL PROTECTED]> wrote: Hi, Is it possible to set dynamic variable value in validation.xml file ? My application is in several language and I would like avoid to define several formset definition according to each language to just change datepatternstrict value. Any idea ? Thanks, Regards Jean-Marie. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator not getting called and I can't see why [resolved]
Romu wrote: U mean a javascript error ? No, I don't use clientside validation on my forms. It's going to the server anyhow so I don't see the point, just an extra layer for things to not work in. u need to define a message.properties file too which will define the error messa Good point, post edited. Bart. 2006/8/6, Bart Busschots <[EMAIL PROTECTED]>: OK, I got all this figured out in the end. The validator was being called but because of problems with the page attribute in the form the validator appears to have been receiving a page value of zero and hence not validating the items on pages 1 or two because neither 1 nor 2 are less that or equal to zero! When I did get the validator to be called it still wasn't working right but I got that fixed too. Anyhow, I did up a blog post about it which can be found here: http://www.bartbusschots.ie/blog/?p=262 If people thing an edited version of this would be a useful addition to the Wiki work away, just credit me or link to the original blog post and I'll be more than happy. Cheers for your help guys, Bart. Bart Busschots wrote: > I'm either missing something stupid (which is always possible) or I've > managed to break the validator. I have an app that uses validator all > over the place and it's working fine in all my other actions but for > this one action it is simply not getting called. > > I can't see any difference between this action/form/validation and all > the other ones that are working. > > This is the form: > > type="org.apache.struts.validator.DynaValidatorForm"> > > > > > > > > This is the action: > > type="vtie.portal.mentor.CreateStudentGroupPrepareAction" > name="createStudentGroupForm" scope="session" validate="true" > input="/home/mentor/addStudentGroupForm.jsp"> >path="/do/mentor/createAnonymousStudentGroup" /> >path="/home/mentor/getStudentNamesForm.jsp" /> > > > > And this is the validation: > > > >mask^[a-zA-Z]+[\w\ > ]*$ > > > > > > > > > > > Can anyone see something obviously wrong there? > > Cheers, > > Bart. > > - > 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 not getting called and I can't see why [resolved]
for example : mentor.createStudentGroup .groupName.label = the Student Group Name 2006/8/7, Romu <[EMAIL PROTECTED]>: U mean a javascript error ? u need to define a message.properties file too which will define the error messa 2006/8/6, Bart Busschots < [EMAIL PROTECTED]>: > OK, I got all this figured out in the end. > > The validator was being called but because of problems with the page > attribute in the form the validator appears to have been receiving a > page value of zero and hence not validating the items on pages 1 or two > because neither 1 nor 2 are less that or equal to zero! When I did get > the validator to be called it still wasn't working right but I got that > fixed too. > > Anyhow, I did up a blog post about it which can be found here: > http://www.bartbusschots.ie/blog/?p=262 > > If people thing an edited version of this would be a useful addition to > the Wiki work away, just credit me or link to the original blog post and > I'll be more than happy. > > Cheers for your help guys, > > Bart. > > Bart Busschots wrote: > > I'm either missing something stupid (which is always possible) or I've > > managed to break the validator. I have an app that uses validator all > > over the place and it's working fine in all my other actions but for > > this one action it is simply not getting called. > > > > I can't see any difference between this action/form/validation and all > > the other ones that are working. > > > > This is the form: > > > > > type="org.apache.struts.validator.DynaValidatorForm"> > > > > > > > > > > > > > > > > This is the action: > > > > > type="vtie.portal.mentor.CreateStudentGroupPrepareAction" > > name="createStudentGroupForm" scope="session" validate="true" > > input="/home/mentor/addStudentGroupForm.jsp"> > >> path="/do/mentor/createAnonymousStudentGroup" /> > >> path="/home/mentor/getStudentNamesForm.jsp" /> > > > > > > > > And this is the validation: > > > > > > > >mask^[a-zA-Z]+[\w\ > > ]*$ > > > > > > > > > > > > > > > > > > > > > > Can anyone see something obviously wrong there? > > > > Cheers, > > > > Bart. > > > > - > > 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 not getting called and I can't see why [resolved]
U mean a javascript error ? u need to define a message.properties file too which will define the error messa 2006/8/6, Bart Busschots <[EMAIL PROTECTED]>: OK, I got all this figured out in the end. The validator was being called but because of problems with the page attribute in the form the validator appears to have been receiving a page value of zero and hence not validating the items on pages 1 or two because neither 1 nor 2 are less that or equal to zero! When I did get the validator to be called it still wasn't working right but I got that fixed too. Anyhow, I did up a blog post about it which can be found here: http://www.bartbusschots.ie/blog/?p=262 If people thing an edited version of this would be a useful addition to the Wiki work away, just credit me or link to the original blog post and I'll be more than happy. Cheers for your help guys, Bart. Bart Busschots wrote: > I'm either missing something stupid (which is always possible) or I've > managed to break the validator. I have an app that uses validator all > over the place and it's working fine in all my other actions but for > this one action it is simply not getting called. > > I can't see any difference between this action/form/validation and all > the other ones that are working. > > This is the form: > > type="org.apache.struts.validator.DynaValidatorForm"> > > > > > > > > This is the action: > > type="vtie.portal.mentor.CreateStudentGroupPrepareAction" > name="createStudentGroupForm" scope="session" validate="true" > input="/home/mentor/addStudentGroupForm.jsp"> >path="/do/mentor/createAnonymousStudentGroup" /> >path="/home/mentor/getStudentNamesForm.jsp" /> > > > > And this is the validation: > > > >mask^[a-zA-Z]+[\w\ > ]*$ > > > > > > > > > > > Can anyone see something obviously wrong there? > > Cheers, > > Bart. > > - > 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]
Validator dynamic var
Hi, Is it possible to set dynamic variable value in validation.xml file ? My application is in several language and I would like avoid to define several formset definition according to each language to just change datepatternstrict value. Any idea ? Thanks, Regards Jean-Marie. --- Email Disclaimer http://www.cofidis.be/emaildisclaimer.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator not getting called and I can't see why [resolved]
OK, I got all this figured out in the end. The validator was being called but because of problems with the page attribute in the form the validator appears to have been receiving a page value of zero and hence not validating the items on pages 1 or two because neither 1 nor 2 are less that or equal to zero! When I did get the validator to be called it still wasn't working right but I got that fixed too. Anyhow, I did up a blog post about it which can be found here: http://www.bartbusschots.ie/blog/?p=262 If people thing an edited version of this would be a useful addition to the Wiki work away, just credit me or link to the original blog post and I'll be more than happy. Cheers for your help guys, Bart. Bart Busschots wrote: I'm either missing something stupid (which is always possible) or I've managed to break the validator. I have an app that uses validator all over the place and it's working fine in all my other actions but for this one action it is simply not getting called. I can't see any difference between this action/form/validation and all the other ones that are working. This is the form: type="org.apache.struts.validator.DynaValidatorForm"> This is the action: type="vtie.portal.mentor.CreateStudentGroupPrepareAction" name="createStudentGroupForm" scope="session" validate="true" input="/home/mentor/addStudentGroupForm.jsp"> path="/do/mentor/createAnonymousStudentGroup" /> path="/home/mentor/getStudentNamesForm.jsp" /> And this is the validation: mask^[a-zA-Z]+[\w\ ]*$ Can anyone see something obviously wrong there? Cheers, Bart. - 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: validate integer with a comma thousands seperator using Validator
Try a mask validator. mask ^\$?\d+(,\d{3})*(\.\d{2})?$ Hubert On 8/4/06, fea jabi <[EMAIL PROTECTED]> wrote: Thanks, Eric. >From: "Givler, Eric" <[EMAIL PROTECTED]> >Reply-To: "Struts Users Mailing List" >To: "Struts Users Mailing List" >Subject: RE: validate integer with a comma thousands seperator using >Validator >Date: Thu, 3 Aug 2006 11:45:28 -0400 > >You could create another validator, and inside that perform a stripping of >non-numeric characters (stripCommas), then >execute code similar to the existing "long range" validator like this: > > > /** > * Determines if a formatted numeric value is between a range as >defined by > * the user-supplied variables: min and max > * > * Note: The only formattting performed is stripping off any commas. >If the > * resulting number does not convert to a Long, then validation will >fail as > * well. > * > * > * Validation succeeds if: > * > *The value in question is null. > *The parsed field value is within the user-supplied >range. > * > * > * @return > * @param application > * @param request > * @param errors > * @param field > * @param va > * @param bean > */ > public static boolean validateFormattedLongRange( > Object bean, > ValidatorAction va, > Field field, > ActionMessages errors, > HttpServletRequest request, > ServletContext application) > { > System.out.println("*** validateFormattedLongRange (" + >field.getProperty() + ") - START"); > boolean isValid = true; > > String value = null; > value = ValidationUtils.evaluateBean(bean, field); > if (!GenericValidator.isBlankOrNull(value)) > { > try > { > long minVal = Long.parseLong(field.getVarValue("min")); > long maxVal = Long.parseLong(field.getVarValue("max")); > // We don't want to do this unless we use map.put to show >tampered value > // value = value.replaceAll("[^-0123456789.]", ""); > value = value.replaceAll("[,]", ""); > long lngValue = Long.parseLong(value); > > if ((lngValue > maxVal) || (lngValue < minVal)) > { > errors.add(field.getKey(), > Resources.getActionMessage(request, va, field)); > isValid = false; > } > } > catch (NumberFormatException nfex) > { > errors.add(field.getKey(), > Resources.getActionMessage(request, va, field)); > isValid = false; > } > } > System.out.println("*** validateFormattedLongRange (" + >field.getProperty() + ") - END, returning " + isValid); > return isValid; > } > >Define this validator in validator-rules.xml: > >classname="view.struts.validator.StrutsValidationExtensions" >method="validateFormattedLongRange" > methodParams="java.lang.Object, >org.apache.commons.validator.ValidatorAction, >org.apache.commons.validator.Field, >org.apache.struts.action.ActionMessages, >javax.servlet.http.HttpServletRequest, >javax.servlet.ServletContext" > msg="errors.fmtLongRange"> > > >Add a rule for a field: > > > > > > > min0 > >max9 > > >Define the message in the resource file (errors.fmtLongRange): > >errors.fmtLongRange={0} must be a valid whole number between {1} and {2}. > > >-Original Message- >From: fea jabi [mailto:[EMAIL PROTECTED] >Sent: Thursday, August 03, 2006 10:01 AM >To: user@struts.apache.org >Subject: RE: validate integer with a comma thousands seperator using >Validator > > >can someone help me with this please? > > > >From: "fea jabi" <[EMAIL PROTECTED]> > >Reply-To: "Struts Users Mailing List" > >To: user@struts.apache.org > >Subject: validate integer with a comma t
Re: RE : Re: Messages and Validator
This comes up regularly on the list - if you feel like documenting the steps on the wiki I'm sure it would be a great help to others :-) http://wiki.apache.org/struts/StrutsDocComments Niall On 8/4/06, Jean-Marie Pitre <[EMAIL PROTECTED]> wrote: Thank you, I have found the solution, I created a custom database-backed ressource bundle with cache and it works well. Regards -Message d'origine- De: news [mailto:[EMAIL PROTECTED] De la part de Laurie Harper Envoyé: mercredi 2 août 2006 23:59 À: user@struts.apache.org Objet: Re: Messages and Validator There's no reason a database-backed message bundle can't load all its messages in one go and cache them. That's all the standard property file-backed implementation does. To provide an alternate message bundle implementation, you just need to configure a custom factory in struts-config.xml; see the commends in the DTD for details. L. Romu wrote: > interesting question , but u will suffer low performance i think ( one > database access for each message ? ) . > > i think if it's in a property file it's for simulate a static class . > > > 2006/8/2, Jean-Marie Pitre <[EMAIL PROTECTED]>: >> >> >> Hello, >> >> I am using Validator framework with a Struts application. >> I would like to know if it is possible to use message provided by a >> database (or java class) rather than a propertie file ? >> >> Thank you, >> >> Jean-Marie. >> >> --- >> Email Disclaimer >> http://www.cofidis.be/emaildisclaimer.php >> >> >> - >> 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: Re: Validator not getting called and I can't see why
Just curios - that's the only createStudentGroupForm instance in your struts config? Since DynaValidatorForm extends DynaActionForm it inherits' the DynaActionForm toString - which always just starts off with "DynaActionForm[..." - in the action, can you log the actual class (form.getClass().getName()) to see what the actual class is - it could be that struts thinks you only have a DynaActionForm instead of a DynaValidatorForm. Cheers, Matt On 8/4/06, Bart Busschots <[EMAIL PROTECTED]> wrote: Hi Niall, I don't seem to be able to get log output form the validator. Maybe I'm doing something wrong? This is my commons-logging.properties file: org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog org.apache.commons.logging.simplelog.defaultlog=debug org.apache.commons.logging.simplelog.showlogname=true org.apache.commons.logging.simplelog.showdatetime=true And this is my simplelog.properties file: org.apache.commons.logging.simplelog.log.org.apache.struts.validator=trace This is not producing any output from the validator at all so I set the default log level to debug and then I see this when I submit the form that is not being validated with no data at all entered (note that every field depends on required): [DEBUG] ModuleUtils - Get module name for path /do [DEBUG] ModuleUtils - Module name found: default [DEBUG] RequestProcessor - Processing a 'POST' for path '/mentor/createStudentGroupStep1' [DEBUG] RequestUtils - Looking for ActionForm bean instance in scope 'session' under attribute key 'createStudentGroupForm' [DEBUG] RequestUtils - Can recycle existing DynaActionForm instance of type 'createStudentGroupForm'?: true [DEBUG] RequestProcessor - Storing ActionForm bean instance in scope 'session' under attribute key 'createStudentGroupForm' [DEBUG] RequestProcessor - Populating bean properties from this request [DEBUG] BeanUtils - BeanUtils.populate(DynaActionForm[dynaClass=createStudentGroupForm,wikiText=,noStudents=,groupName=,groupType=MINORS,studentNames={}], {wikiText=[Ljava.lang.String;@c8d24, page=[Ljava.lang.String;@666b9, noStudents=[Ljava.lang.String;@4200d3, groupName=[Ljava.lang.String;@443251, groupType=[Ljava.lang.String;@438e8c}) [DEBUG] ConvertUtils - Convert string '' to class 'java.lang.String' [DEBUG] ConvertUtils - Convert string '' to class 'java.lang.String' [DEBUG] ConvertUtils - Convert string '' to class 'java.lang.String' [DEBUG] ConvertUtils - Convert string 'MINORS' to class 'java.lang.String' [DEBUG] RequestProcessor - Validating input form properties [DEBUG] RequestProcessor - Looking for Action instance for class vtie.portal.mentor.CreateStudentGroupPrepareAction [DEBUG] PropertyMessageResources - getMessage(en_US,unhandledException) [WARN] RequestProcessor - Unhandled Exception thrown: class java.lang.NumberFormatException To my un-trained eye this looks like the validator is being called but not doing what it should, i.e. throwing a wobbler when it gets no data in any field. The validation for the form in validation.xml is as follows: mask^[a-zA-Z]+[\w\ ]*$ Does any of this make sense to you and can you see anything odd in the traces above? Thanks, Bart. Niall Pemberton wrote: > Try turning on logging in debug mode, should give you more info about > what its doing. > > Niall > > On 8/3/06, Bart Busschots <[EMAIL PROTECTED]> wrote: >> I'm either missing something stupid (which is always possible) or I've >> managed to break the validator. I have an app that uses validator all >> over the place and it's working fine in all my other actions but for >> this one action it is simply not getting called. >> >> I can't see any difference between this action/form/validation and all >> the other ones that are working. >> >> This is the form: >> >> > type="org.apache.struts.validator.DynaValidatorForm"> >> >> >> >> >> >> >> >> This is the action: >> >> > type="vtie.portal.mentor.CreateStudentGroupPrepareAction" >> name="createStudentGroupForm" scope="session" validate="true" >> input="/home/mentor/addStudentGroupForm.jsp"> >>> path="/do/mentor/createAnonymousStudentGroup" /> >>> path="/home/mentor/getStudentNamesForm.jsp" /> >> >> >> >> And this is the validation: >> >> >> >> mask^[a-zA-Z]+[\w\ >> ]*$ >> >> >> >> >> >> >> >> >>
Re: Validator not getting called and I can't see why
On 8/5/06, Bart Busschots <[EMAIL PROTECTED]> wrote: Hi Niall, I don't seem to be able to get log output form the validator. Maybe I'm doing something wrong? This is my commons-logging.properties file: org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog org.apache.commons.logging.simplelog.defaultlog=debug org.apache.commons.logging.simplelog.showlogname=true org.apache.commons.logging.simplelog.showdatetime=true And this is my simplelog.properties file: org.apache.commons.logging.simplelog.log.org.apache.struts.validator=trace This is not producing any output from the validator at all so I set the default log level to debug and then I see this when I submit the form that is not being validated with no data at all entered (note that every field depends on required): [DEBUG] ModuleUtils - Get module name for path /do [DEBUG] ModuleUtils - Module name found: default [DEBUG] RequestProcessor - Processing a 'POST' for path '/mentor/createStudentGroupStep1' [DEBUG] RequestUtils - Looking for ActionForm bean instance in scope 'session' under attribute key 'createStudentGroupForm' [DEBUG] RequestUtils - Can recycle existing DynaActionForm instance of type 'createStudentGroupForm'?: true [DEBUG] RequestProcessor - Storing ActionForm bean instance in scope 'session' under attribute key 'createStudentGroupForm' [DEBUG] RequestProcessor - Populating bean properties from this request [DEBUG] BeanUtils - BeanUtils.populate(DynaActionForm[dynaClass=createStudentGroupForm,wikiText=,noStudents=,groupName=,groupType=MINORS,studentNames={}], {wikiText=[Ljava.lang.String;@c8d24, page=[Ljava.lang.String;@666b9, noStudents=[Ljava.lang.String;@4200d3, groupName=[Ljava.lang.String;@443251, groupType=[Ljava.lang.String;@438e8c}) [DEBUG] ConvertUtils - Convert string '' to class 'java.lang.String' [DEBUG] ConvertUtils - Convert string '' to class 'java.lang.String' [DEBUG] ConvertUtils - Convert string '' to class 'java.lang.String' [DEBUG] ConvertUtils - Convert string 'MINORS' to class 'java.lang.String' [DEBUG] RequestProcessor - Validating input form properties [DEBUG] RequestProcessor - Looking for Action instance for class vtie.portal.mentor.CreateStudentGroupPrepareAction [DEBUG] PropertyMessageResources - getMessage(en_US,unhandledException) [WARN] RequestProcessor - Unhandled Exception thrown: class java.lang.NumberFormatException To my un-trained eye this looks like the validator is being called but not doing what it should, i.e. throwing a wobbler when it gets no data in any field. The validation for the form in validation.xml is as follows: mask^[a-zA-Z]+[\w\ ]*$ Does any of this make sense to you and can you see anything odd in the traces above? Validator is throwing a wobbler like you said. You have the DEBUG message from the RequestProcessor before it does validation - but there should be one after saying either there were errors or that everything was OK. You need to find out what the exception being thrown is for - create a custom DynaValidatorForm and trap the exception and get the cause. The other thing that someone else pointed out is that you have used the "page" attribute in your validation.xml, but not defined it as a property for your DynaValidatorForm - so maybe its something to do with that. Anyway the root of the problem is the exception being throw - find out what that is and it should shed a whole lot more light on the problem. Niall Thanks, Bart. Niall Pemberton wrote: > Try turning on logging in debug mode, should give you more info about > what its doing. > > Niall > > On 8/3/06, Bart Busschots <[EMAIL PROTECTED]> wrote: >> I'm either missing something stupid (which is always possible) or I've >> managed to break the validator. I have an app that uses validator all >> over the place and it's working fine in all my other actions but for >> this one action it is simply not getting called. >> >> I can't see any difference between this action/form/validation and all >> the other ones that are working. >> >> This is the form: >> >> > type="org.apache.struts.validator.DynaValidatorForm"> >> >> >> >> >> >> >> >> This is the action: >> >> > type="vtie.portal.mentor.CreateStudentGroupPrepareAction" >> name="createStudentGroupForm" scope="session" validate="true" >> input="/home/mentor/addStudentGroupForm.jsp"> >>> path="/do/mentor/createAnonymousStudentGroup" /> >>>
Re: Validator not getting called and I can't see why
Hi Niall, I don't seem to be able to get log output form the validator. Maybe I'm doing something wrong? This is my commons-logging.properties file: org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog org.apache.commons.logging.simplelog.defaultlog=debug org.apache.commons.logging.simplelog.showlogname=true org.apache.commons.logging.simplelog.showdatetime=true And this is my simplelog.properties file: org.apache.commons.logging.simplelog.log.org.apache.struts.validator=trace This is not producing any output from the validator at all so I set the default log level to debug and then I see this when I submit the form that is not being validated with no data at all entered (note that every field depends on required): [DEBUG] ModuleUtils - Get module name for path /do [DEBUG] ModuleUtils - Module name found: default [DEBUG] RequestProcessor - Processing a 'POST' for path '/mentor/createStudentGroupStep1' [DEBUG] RequestUtils - Looking for ActionForm bean instance in scope 'session' under attribute key 'createStudentGroupForm' [DEBUG] RequestUtils - Can recycle existing DynaActionForm instance of type 'createStudentGroupForm'?: true [DEBUG] RequestProcessor - Storing ActionForm bean instance in scope 'session' under attribute key 'createStudentGroupForm' [DEBUG] RequestProcessor - Populating bean properties from this request [DEBUG] BeanUtils - BeanUtils.populate(DynaActionForm[dynaClass=createStudentGroupForm,wikiText=,noStudents=,groupName=,groupType=MINORS,studentNames={}], {wikiText=[Ljava.lang.String;@c8d24, page=[Ljava.lang.String;@666b9, noStudents=[Ljava.lang.String;@4200d3, groupName=[Ljava.lang.String;@443251, groupType=[Ljava.lang.String;@438e8c}) [DEBUG] ConvertUtils - Convert string '' to class 'java.lang.String' [DEBUG] ConvertUtils - Convert string '' to class 'java.lang.String' [DEBUG] ConvertUtils - Convert string '' to class 'java.lang.String' [DEBUG] ConvertUtils - Convert string 'MINORS' to class 'java.lang.String' [DEBUG] RequestProcessor - Validating input form properties [DEBUG] RequestProcessor - Looking for Action instance for class vtie.portal.mentor.CreateStudentGroupPrepareAction [DEBUG] PropertyMessageResources - getMessage(en_US,unhandledException) [WARN] RequestProcessor - Unhandled Exception thrown: class java.lang.NumberFormatException To my un-trained eye this looks like the validator is being called but not doing what it should, i.e. throwing a wobbler when it gets no data in any field. The validation for the form in validation.xml is as follows: mask^[a-zA-Z]+[\w\ ]*$ Does any of this make sense to you and can you see anything odd in the traces above? Thanks, Bart. Niall Pemberton wrote: Try turning on logging in debug mode, should give you more info about what its doing. Niall On 8/3/06, Bart Busschots <[EMAIL PROTECTED]> wrote: I'm either missing something stupid (which is always possible) or I've managed to break the validator. I have an app that uses validator all over the place and it's working fine in all my other actions but for this one action it is simply not getting called. I can't see any difference between this action/form/validation and all the other ones that are working. This is the form: This is the action: And this is the validation: mask^[a-zA-Z]+[\w\ ]*$ Can anyone see something obviously wrong there? Cheers, Bart. - 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 not getting called and I can't see why
Try turning on logging in debug mode, should give you more info about what its doing. Niall On 8/3/06, Bart Busschots <[EMAIL PROTECTED]> wrote: I'm either missing something stupid (which is always possible) or I've managed to break the validator. I have an app that uses validator all over the place and it's working fine in all my other actions but for this one action it is simply not getting called. I can't see any difference between this action/form/validation and all the other ones that are working. This is the form: This is the action: And this is the validation: mask^[a-zA-Z]+[\w\ ]*$ Can anyone see something obviously wrong there? Cheers, Bart. - 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 not getting called and I can't see why
Sure you can, just follow Eric's example and subclass DynaValidatorForm. Then change your form-bean declaration to ... Adam -Original Message- From: Bart Busschots [mailto:[EMAIL PROTECTED] Sent: Friday, August 04, 2006 10:41 AM To: Struts Users Mailing List Subject: Re: Validator not getting called and I can't see why Hi Eric, Thanks for the reply but I'm using a DynaValidatorForm so I don't have a class to override things in. I would assume that DynaValidatorForm validates correctly because I use it all over the place. It's just this one action that's not validating and I just can't see what's different here. Bart. Givler, Eric wrote: > Can you override the validate() method inside your form and just call super.validate(), then see what the error collection has? > At least then you know it was called, but may not have done what you thought it should: > > package view.struts.forms; > > import javax.servlet.http.HttpServletRequest; > > import org.apache.log4j.Logger; > import org.apache.struts.action.ActionErrors; > import org.apache.struts.action.ActionMapping; > import org.apache.struts.validator.DynaValidatorForm; > > public class Page_6_Form extends DynaValidatorForm { >private static Logger log = Logger.getLogger(Page_6_Form.class); > >public ActionErrors validate(ActionMapping mapping, > HttpServletRequest request) { > > log.info( request.getRemoteUser() + " *** validate() - Start > ***"); > > // step in here with debug > ActionErrors errors = super.validate(mapping, request); > > // look at results of errors object as watch on first test > log.info( request.getRemoteUser() + " *** validate - End, errors= " + > ( errors == null ? "0" : errors.size()+"" ) + " ***"); > > return ( errors ); >} // validate > > } // Page_6_Form > > > -Original Message- > From: Bart Busschots [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 03, 2006 6:10 PM > To: Struts Users Mailing List > Subject: Validator not getting called and I can't see why > > > I'm either missing something stupid (which is always possible) or I've > managed to break the validator. I have an app that uses validator all > over the place and it's working fine in all my other actions but for > this one action it is simply not getting called. > > I can't see any difference between this action/form/validation and all > the other ones that are working. > > This is the form: > >type="org.apache.struts.validator.DynaValidatorForm"> > > > > > > > > This is the action: > >type="vtie.portal.mentor.CreateStudentGroupPrepareAction" > name="createStudentGroupForm" scope="session" validate="true" > input="/home/mentor/addStudentGroupForm.jsp"> > path="/do/mentor/createAnonymousStudentGroup" /> > path="/home/mentor/getStudentNamesForm.jsp" /> > > > > And this is the validation: > > > > mask^[a-zA-Z]+[\w\ > ]*$ > > > > > > > > > > > Can anyone see something obviously wrong there? > > Cheers, > > Bart. > > - > 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] - The information contained in this message may be privileged, confidential, and protected from disclosure. If the reader of this message is not the intended recipient, or any employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. Paychex, Inc. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Validator lost data when go back to form
It *appears* you are redirecting the user in which case you are losing all of the users session Data You may want to define the ActionMapping to forward the request and ensure redirect=false Here is an explanation of the use of redirect vs forward http://www.mail-archive.com/struts-user@jakarta.apache.org/msg21820.html Here is doc on implementation details for the use of redirect for ActionForward http://www.ingrid.org/jajakarta/struts/struts1.0/en/target/documentation/api/org/apache/struts/action/ActionForward.html#ActionForward(java.lang.String,%20boolean) Anyone else? Martin-- __ Disclaimer and confidentiality note Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. Hi, I'am using validator to validate data on client side and server side. It works fine, but when I validate on server side when there are errors detected I go back to the html but without user data (the form is reseted). Have you got any idea ? Thanks in advance, Jean-Marie. -Message d'origine- De : fea jabi [mailto:[EMAIL PROTECTED] Envoyé : vendredi 4 août 2006 15:24 À : user@struts.apache.org Objet : RE: validate integer with a comma thousands seperator using Validator Thanks, Eric. >From: "Givler, Eric" <[EMAIL PROTECTED]> >Reply-To: "Struts Users Mailing List" >To: "Struts Users Mailing List" >Subject: RE: validate integer with a comma thousands seperator using >Validator >Date: Thu, 3 Aug 2006 11:45:28 -0400 > >You could create another validator, and inside that perform a stripping of >non-numeric characters (stripCommas), then >execute code similar to the existing "long range" validator like this: > > > /** > * Determines if a formatted numeric value is between a range as >defined by > * the user-supplied variables: min and max > * > * Note: The only formattting performed is stripping off any commas. >If the > * resulting number does not convert to a Long, then validation will >fail as > * well. > * > * > * Validation succeeds if: > * > *The value in question is null. > *The parsed field value is within the user-supplied >range. > * > * > * @return > * @param application > * @param request > * @param errors > * @param field > * @param va > * @param bean > */ > public static boolean validateFormattedLongRange( > Object bean, > ValidatorAction va, > Field field, > ActionMessages errors, > HttpServletRequest request, > ServletContext application) > { > System.out.println("*** validateFormattedLongRange (" + >field.getProperty() + ") - START"); > boolean isValid = true; > > String value = null; > value = ValidationUtils.evaluateBean(bean, field); > if (!GenericValidator.isBlankOrNull(value)) > { > try > { > long minVal = Long.parseLong(field.getVarValue("min")); > long maxVal = Long.parseLong(field.getVarValue("max")); > // We don't want to do this unless we use map.put to show >tampered value > // value = value.replaceAll("[^-0123456789.]", ""); > value = value.replaceAll("[,]", ""); > long lngValue = Long.parseLong(value); > > if ((lngValue > maxVal) || (lngValue < minVal)) > { > errors.add(field.getKey(), > Resources.getActionMessage(request, va, field)); > isValid = false; > } > } > catch (NumberFormatException nfex) > { > errors.add(field.getKey(), > Resources.getActionMessage(request, va, field)); > isValid = false; > } > } > System.out.println("*** validateFormattedLongRange (" + >field.getProperty() + ") - END, returning " + isValid); > return isValid; > } > >Define this validator in validator-rules.xml: > >classname="view.struts.validator.StrutsValidationExtensions" >method="validateFormattedLongRa
Re: Validator not getting called and I can't see why
Hi Eric, Thanks for the reply but I'm using a DynaValidatorForm so I don't have a class to override things in. I would assume that DynaValidatorForm validates correctly because I use it all over the place. It's just this one action that's not validating and I just can't see what's different here. Bart. Givler, Eric wrote: Can you override the validate() method inside your form and just call super.validate(), then see what the error collection has? At least then you know it was called, but may not have done what you thought it should: package view.struts.forms; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; public class Page_6_Form extends DynaValidatorForm { private static Logger log = Logger.getLogger(Page_6_Form.class); public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { log.info( request.getRemoteUser() + " *** validate() - Start ***"); // step in here with debug ActionErrors errors = super.validate(mapping, request); // look at results of errors object as watch on first test log.info( request.getRemoteUser() + " *** validate - End, errors= " + ( errors == null ? "0" : errors.size()+"" ) + " ***"); return ( errors ); } // validate } // Page_6_Form -Original Message- From: Bart Busschots [mailto:[EMAIL PROTECTED] Sent: Thursday, August 03, 2006 6:10 PM To: Struts Users Mailing List Subject: Validator not getting called and I can't see why I'm either missing something stupid (which is always possible) or I've managed to break the validator. I have an app that uses validator all over the place and it's working fine in all my other actions but for this one action it is simply not getting called. I can't see any difference between this action/form/validation and all the other ones that are working. This is the form: type="org.apache.struts.validator.DynaValidatorForm"> This is the action: type="vtie.portal.mentor.CreateStudentGroupPrepareAction" name="createStudentGroupForm" scope="session" validate="true" input="/home/mentor/addStudentGroupForm.jsp"> path="/do/mentor/createAnonymousStudentGroup" /> path="/home/mentor/getStudentNamesForm.jsp" /> And this is the validation: mask^[a-zA-Z]+[\w\ ]*$ Can anyone see something obviously wrong there? Cheers, Bart. - 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]