Results 1 to 2 of 2
  1. #1
    fierof2 is offline Member
    Join Date
    Jul 2010
    Posts
    24
    Rep Power
    0

    Exclamation Unnable to make validations work.

    Hi All

    I am breaking my head for a long time. Everything seems to be fine but I am not able to apply validation framework to my login screen. Everything seems to be fine but still validation is not working. Currently what i am trying to achieve, is to throw error message when the user doesnt enter the username in the login screen.

    The attached zip file contains the entire code i have developed but cant figure out what mistake i have made. Even though i don't enter the user name in the login screen the action gets executed and error message is not displayed. It would be really great if someone could identify what mistake i have made in the code.

    Fierof2
    Attached Files Attached Files

  2. #2
    fierof2 is offline Member
    Join Date
    Jul 2010
    Posts
    24
    Rep Power
    0

    Default

    Below is the content of login.jsp file
    -----------------------------------------
    XML Code:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1" errorPage="error.jsp"%>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <!doctype html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Repository</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="js/shadedborder.js"></script>
    <script type="text/javascript" src="js/ajax.js"> </script>
    <link href="css/style.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <html:form action="/login" method="POST">
    
    <div id="content">
      <div id="innerholder">
        <h3><span></span></h3>
            	<div>
                	<div id="usernamelbl"><b><bean:message bundle="html" key="label.login.username"/> :</b></div>
                    <div class="roundedfield" >
                    	<html:text property="username" styleId="username"/>  
                    </div>
                </div>
                <div>
                    <div id="passwordlbl"><b><bean:message bundle="html" key="label.login.password"/> :</b></div>
                    <div class="roundedfield" >
                    <html:password property="password" styleId="password"/>
                    </div>    
                </div>
                <div>
                    <div id="projectlbl"><b><bean:message bundle="html" key="label.login.project"/> :</b></div>
                    <div class="nonroundedfield">
                    <html:select property="project"><html:option value=""></html:option></html:select> 
                    </div>    
                </div>
                <br />
                <html:button property="authenticatebutton" onclick="authenticate();" styleId="authenticatebutton">
                <bean:message bundle="html" key="btn.login.authenticate"/></html:button> 
                <html:submit property="loginbutton" styleId="loginbutton">
                <bean:message bundle="html" key="btn.login.login"/></html:submit> 
      </div>
    </div>
    </html:form>
    <font color="red">
    <html:errors/>
    </font>
    <script language="javascript" type="text/javascript">  
        holderBorder.render('content');
    </script>
    </body>
    </html>
    below is the content of Struts-config file

    -----------------------------------------
    Java Code:
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
    <struts-config>
    
    
    <!-- ================================================ Form Bean Definitions -->
    
        <form-beans>
    	<form-bean 
    		name="loginForm"
    		type="com.attragroup.tcr.forms.LoginForm" />
        </form-beans>
    
    
    <!-- ========================================= Global Exception Definitions -->
    
        <global-exceptions>
            <!-- sample exception handler
            <exception
                key="expired.password"
                type="app.ExpiredPasswordException"
                path="/changePassword.jsp"/>
            end sample -->
        </global-exceptions>
    
    
    <!-- =========================================== Global Forward Definitions -->
    
        <global-forwards>
            <!-- Default forward to "Welcome" action -->
            <!-- Demonstrates using index.jsp to forward -->
            <forward name="login" path="/login.jsp" />
        </global-forwards>
    
    
    <!-- =========================================== Action Mapping Definitions -->
    
        <action-mappings>
                <!-- Default "Welcome" action -->
                <!-- Forwards to Welcome.jsp -->
            <action path="/login" type="com.attragroup.tcr.action.LoginAction" name="loginForm" scope="request" input="/login.jsp" unknown="true" />
            <action path="/authenticate" type="com.attragroup.tcr.action.AuthenticateProjectAction" />
            <action path="/Welcome" forward="/pages/Welcome.jsp" />
    
        
        </action-mappings>
    
    
    <!-- ======================================== Message Resources Definitions -->
    
        <message-resources parameter="com.attragroup.tcr.settings.MessageResources" key="html" />
        <message-resources parameter="com.attragroup.tcr.settings.ErrorResources"  key="error" />
    
    
    <!-- =============================================== Plug Ins Configuration -->
    
    
      <!-- =================================================== Validator plugin -->
    
        <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
            <set-property property="pathnames" value="/org/apache/struts/validator/validator-rules.xml,
               /WEB-INF/validation.xml" />
        </plug-in>
    
    </struts-config>
    Below is the content of validations.xml

    Java Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    
    <!DOCTYPE form-validation PUBLIC
         "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN"
         "http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">
    
    <form-validation>
    
    <!--
         This is a minimal Validator form file with a couple of examples.
    -->
    
        <global>
    
    
        </global>
    
        <formset>
    
            <!-- An example form -->
            <form name="loginForm">
                <field
                    property="username"
                    depends="required">
                     <arg position="0" bundle="error" key="error.required"/>
                    <!-- <msg name="required" bundle="error" key="loginForm.username"></msg>
                    <msg name="minLength" bundle="error" key="loginForm.username.minlength"></msg>
                    <arg name="minLength" key="${var:minlength}" position="0" resource="false" />
                    <var>
    					<var-name>minlength</var-name>
    					<var-value>5</var-value>
    				</var>  -->
                        
                </field>
            </form>
    
        </formset>
    
      
    
    </form-validation>

Similar Threads

  1. How do i make this work What am i doing Wrong.
    By Ramaan in forum New To Java
    Replies: 2
    Last Post: 03-02-2010, 12:36 AM
  2. Make the Button Work
    By ŖΫ ỏ Ңόρę in forum New To Java
    Replies: 1
    Last Post: 02-27-2010, 11:52 AM
  3. Cannot make Java6 update10 work
    By Sphacelaria in forum New To Java
    Replies: 5
    Last Post: 12-01-2008, 04:48 AM
  4. Can't make JTable work -- please help!!
    By cagalli83 in forum Advanced Java
    Replies: 0
    Last Post: 02-13-2008, 10:31 AM
  5. To make work DLL from webservices
    By Felissa in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 08:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •