472,780 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

struts 2 validation.xml not validating.

I can't seem to get Struts 2 validations to work. I have been converting from Strust 1 to Struts 2. So far I've refactored all the code (for this particular module) on the back end, rewrote the jsp using Struts 2 notations, and wired up the xml (aside from the abc-validation.xml). Everything runs just fine. If there is an error not generated by user input (i.e. file format problem) I can get that message to come out, so I know my error messages work. I try to add the abc-validation.xml for my abc class, but the validations never catch. The input field types I'm using are of select (x3) and file(x1). The selects all use numbers (default 0), and the file is just a file path (default blank). I set my validation.xml (below) to have a min of 1 for the selects, and required for the file field. So when I hit submit I expect something to come back with out hitting my action class, but it doesn't. My action does extend ActionSupport and implements RequestAware. Can anyone point me in the right direction?
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
  3.        "http://www.opensymphony.com/xwork/xw...ator-1.0.2.dtd">
  4. <validators>
  5.  <field name="typeId">
  6.   <field-validator type="int">
  7.    <param name="min">1</param>
  8.    <message>Message</message>
  9.   </field-validator>
  10.  </field>
  11.  <field name="month">
  12.   <field-validator type="int">
  13.    <param name="min">1</param>
  14.    <message>Message</message>
  15.   </field-validator>
  16.  </field>
  17.  <field name="year">
  18.   <field-validator type="int">
  19.    <param name="min">1988</param>
  20.    <message>Message</message>
  21.   </field-validator>
  22.  </field>
  23.  <field name="inputFile">
  24.   <field-validator type="required">
  25.    <message>Message</message>
  26.   </field-validator>
  27.  </field>
  28. </validators>
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE struts PUBLIC
  3.     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  4.     "http://struts.apache.org/dtds/struts-2.0.dtd">
  5. <struts>
  6.  <package name="loadFile" namespace="/secure"
  7.   extends="struts-default">
  8.   <result-types>
  9.    <result-type name="tiles"
  10.     class="org.apache.struts2.views.tiles.TilesResult" />
  11.   </result-types>
  12.   <action name="loadFile">
  13.    <result type="tiles">.user.LoadFile</result>
  14.   </action>
  15.   <action name="LoadUserFile"
  16.    class="com.organization.struts.user.UserFileLoadAction">
  17.    <interceptor-ref name="paramsPrepareParamsStack" />
  18.    <interceptor-ref name="defaultStack" />
  19.    <interceptor-ref name="validation">
  20.     <param name="excludeMethods">
  21.      input,back,cancel,browse
  22.     </param>
  23.    </interceptor-ref>
  24.    <interceptor-ref name="roles">
  25.     <param name="allowedRoles">UserFile-Upload</param>
  26.    </interceptor-ref>
  27.    <result name="success" type="tiles">
  28.     .user.loadSuccessful
  29.    </result>
  30.    <result name="cancel" type="tiles">/secure/home.do</result>
  31.    <result name="error" type="tiles">.user.LoadFile</result>
  32.   </action>
  33.  </package>
  34. </struts>
Jan 21 '09 #1
1 11406
For default implementation of validation you must have at least one result with name error/input.
Oct 25 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Alex M | last post by:
I'm trying to use the jakarta struts client side javascript validators and the validators are working, but they are not showing the popup messages. I have the message keys defined in the...
by: Tim Frawley | last post by:
Source code attached indicates my problem with validation and a button bar save button. Fill the Textbox with some text then tab off the control. The message box will display the text in the...
by: Micky | last post by:
VB v7.1.3088 NET v1.1.4322 SP1 My mate has a strange problem regarding the ESC key and validation. When he hits the Cancel button on his form, the form does not validate. This is correct...
by: Prasanth Nair | last post by:
hi, When I add the following in struts-config.xml, I am getting the below mentioned error while starting the server. /***********************Struts entry**********************/ <plug-in...
by: nithiya sri | last post by:
i am new to struts.I try running struts application in Eclipse with the tomcat plug in .. it shows the following error:; please help me in this... SEVERE: Error loading WebappClassLoader ...
by: PaulCarmo | last post by:
Hello, I'm validating a form containing various types of data. One of the fields to be validated is an amount which must be between 0.01 and 999999.99. The code for this field validation in the...
by: ajos | last post by:
hi frnds, the situation is im developing a web application in struts-- my specifications-eclipse3.2.2,struts1.1,tomcat5.5.23 mysql5.0 db. the scenario-i have a jsp page which adds the...
by: gavy7210 | last post by:
hello i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk 1.5.. i have a login form(jsp) in which a user logs in,in case he doesnt enter his username and/or password an error...
by: madhuriks | last post by:
hi, i m using Struts 2 in my application...im doing validation...my problem is it is validating all the fields expect the last field..i used cost in my jsp page..it is getting validated but the...
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.