Solved

Struts validator status 404 action not avaliable

Posted on 2006-07-20
5
529 Views
Last Modified: 2008-02-01
i am using struts Actionerror was working fine but validator is not working

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<html>
<head>


 <title>
 </title>
  <body >


  <html:errors/>
    <html:form action="/valviji" onsubmit="return validateLookupform(this)" >
 

     <table width="45%" border=0>
      <tr>
       <td> Symbol </td>
            <td> <html:text property="symbol"/></td>
            <td><bean:message key="Lookupform.symbol" />
         </tr>
            <tr>
                  <td>
                        </td>
                 <td> <html:submit property="submit" value="submit"/></td>

                        </tr>
            </table>
  </html:form>
 </body>
</html>

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

<form-validation>

<!--
     This is a minimal Validator form file with a couple of examples.
-->

    <global>

        <!-- A-->
        <constant>
   <constant-name>symbolformat</constant-name>
   <constant-value>^[A-Za-z0-9]*$</constant-value>
   </constant>
     <!--    example-->

    </global>

    <formset>

        <!-- An example form -->
        <form name="Lookupform">
            <field
                property="symbol"
                depends="required,mask">
                    <arg0 key="Lookupform.symbol"/>

                              <var>      
                              <!--  mask change -->
             <var-name>symbolformat</var-name>
             <var-value>^[A-za-z0-9]*$</var-value>
             </var>
            </field>
           
        </form>

    </formset>

   
</form-validation>






































<!-- <?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
          "http://jakarta.apache.org/commons/dtds/validation_1_1.dtd">

<form-validation>
  <global>
   
</global>
   
    <formset>
     <form name="Lookupform">
           
            <field property="symbol" depends="required,mask">
            <arg0 key="Lookupform.symbol"/>
           <var>      
             <var-name>mask</var-name>
             <var-value>^[A-za-z0-9]*$</var-value>
             </var>
          </field>                          
     
     </form>
    </formset>


</form-validation>-->



<validator name="required"
          classname="org.apache
.struts.validator.FieldChecks"
          method="validateRequired"
          methodParams="java.lang
.Object, org.apache.commons.validator
.ValidatorAction, org.apache.commons
.validator.Field, org.apache.struts
.action.ActionErrors, javax.servlet
.http.HttpServletRequest"
          msg="errors.required">
     
     
      title = Welcome to Struts Application
heading= Example for Internationalization
error.lookup.symbol.required=A Valid Symbol is Required
errors.lookup.unknown=An UnKnown Symbol {0}.Enter a Proper Symbol.
errors.header=<h3><font color="red"> Error List </font></h3>
errors.footer=<br>End of Error Message


Lookupform.symbol.proplem=the blank areaname
Lookupform.symbol=symbol
symbol.error=Correct Symbol
errors.required={0} is required.
sym.err={0}Invalid symbol
errors.invalid={0} is invalid.

plz send details about my above program ana what i did wrong
0
Comment
Question by:saravananvg
  • 2
5 Comments
 
LVL 30

Accepted Solution

by:
mayankeagle earned 25 total points
ID: 17144839
>> classname="org.apache
>> .struts.validator.FieldChecks"

Is there a new-line there in the file? I'm not sure if it would work but I'll prefer being on the safer side with:

classname="org.apache.struts.validator.FieldChecks"

so on....

0
 
LVL 4

Assisted Solution

by:orhanbaba
orhanbaba earned 25 total points
ID: 17152636
you will put this in your validator.xml
<!-- Tast form Validation-->
<form name="TestForm">
    <field  property="username"
          depends="required">
         <arg key="username.name"/>
    </field>
</form>

in jsp page
html stuff...

<html:form action="/TestValidation" method="post" onsubmit="return validateTestForm(this);">
<html:text property="username" size="25" maxlength="25"/>
<html:submit>Check</html:submit>
<!-- Begin Attention Here-->
<html:javascript formName="TestForm"/><!-- you didnt put this in your code -->
<!-- End Attention Here :) -->
</html:form>

html stuff...

If you are working with eclipse sometimes you need to restart tomcat when you change the xml files.
0
 
LVL 4

Expert Comment

by:orhanbaba
ID: 17152670
and put validate="true" in your struts action configuration.
<action
.
.
.
     validate="true"
.
.
</action>
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
network + 7 73
base64 decode encode 12 97
create a gui in perl 3 45
recursion example 16 70
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now