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

    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.

    Attached Files Attached Files

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


    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="" prefix="html" %>
    <%@ taglib uri="" prefix="bean" %>
    <!doctype html>
    <html xmlns="">
    <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">
    <html:form action="/login" method="POST">
    <div id="content">
      <div id="innerholder">
                	<div id="usernamelbl"><b><bean:message bundle="html" key="label.login.username"/> :</b></div>
                    <div class="roundedfield" >
                    	<html:text property="username" styleId="username"/>  
                    <div id="passwordlbl"><b><bean:message bundle="html" key="label.login.password"/> :</b></div>
                    <div class="roundedfield" >
                    <html:password property="password" styleId="password"/>
                    <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> 
                <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> 
    <font color="red">
    <script language="javascript" type="text/javascript">  
    below is the content of Struts-config file

    Java Code:
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "">
    <!-- ================================================ Form Bean Definitions -->
    		type="com.attragroup.tcr.forms.LoginForm" />
    <!-- ========================================= Global Exception Definitions -->
            <!-- sample exception handler
            end sample -->
    <!-- =========================================== Global Forward Definitions -->
            <!-- Default forward to "Welcome" action -->
            <!-- Demonstrates using index.jsp to forward -->
            <forward name="login" path="/login.jsp" />
    <!-- =========================================== Action Mapping Definitions -->
                <!-- 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" />
    <!-- ======================================== 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" />
    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"
         This is a minimal Validator form file with a couple of examples.
            <!-- An example form -->
            <form name="loginForm">
                     <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>  -->

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