You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by vani patange <ar...@hotmail.com> on 2007/07/15 10:35:28 UTC

validation problem with javascript method validateForm_Login() not available

Hi
iam newbie to struts2 i handled validation in struts 1.3 but in struts2 even
i follow validation instruction iam  getting javascript error saying
"validateForm_Login();" method not available.
iam validating one form of Login.jsp  and my code goes like this 

Login.jsp

<body>
    <s:form action="Login.action" validate="true">
        <table>
            
            <tr><td><s:textfield name="username" label="UserName"/></td><tr>
            <tr><td><s:password name="password" label="PassWord"/></td><tr>    
            <tr><td> <input type="submit"/>  </td></tr>
        </table>
    </s:form>

</body>


Login.java
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3)
// Source File Name:   HelloWorld.java



package tutorial;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.io.PrintStream;
import org.apache.struts2.views.jsp.TagUtils;
import org.apache.log4j.Logger;
public class Login extends ActionSupport
{

    public Login()
    {
    }

    public String execute()
        throws Exception
    {
        
        System.out.println("inside execute method of Login");
	return "success";
    }

    public void setPassword(String s)
    {
        System.out.println("first setPassword has invoked"+s);
        password = s;
    }

    public String getPassword()
    {
        return password;
    }

	public String getUsername()
	{
         System.out.println("first getUsername has invoked");
		return username;
	}

	public void setUsername(String us)
    {
       System.out.println("first setUsername has invoked"+us);
        username = us;
    }


    public static final String MESSAGE = "Struts is up and running ...";
    private String username;
    private String password;
}

Login-validation.xml

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator
1.0.2//EN"
       "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
       <validators>
           <field name="username">
               <field-validator type="required">
                   <message>you must enter a username </message>
           </field>
           <field name="password">
               <field-validator type="required">
                   <message>you must enter a password </message>
           </field>
       </validators>


struts.xml
<struts>
<package>
 <interceptor name="validator"
class="com.opensymphony.xwork2.validator.ValidationInterceptor"/>
    <package name="tutorial" extends="struts-default">
<action name="Login" class="tutorial.Login">
            <result name="success">/loginsuccess.jsp</result>
            <result name="error">/Error.html</result>       
        
        </action>


        <!-- Add your actions here -->
    </package>
</struts>


and on view source of Login.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome!</title>

</head>
<body>
    	<script type="text/javascript"
src="/netstruts2/struts/xhtml/validation.js"></script>
		
<form namespace="" id="Login" onsubmit="return validateForm_Login();"
action="Login.action" method="post">
<table class="wwFormTable">
        <table>
        
            <tr><td><tr>
    <td class="tdLabel"><label for="Login_username"
class="label">UserName:</label></td>
    <td
><input type="text" name="username" value="" id="Login_username"/>
</td>
</tr>
</td><tr>
            <tr><td><tr>
    <td class="tdLabel"><label for="Login_password"
class="label">PassWord:</label></td>
    <td
><input type="password" name="password" id="Login_password"/>

</td>
</tr>
</td><tr>    
            <tr><td> <input type="submit"/>  </td></tr>
        </table>
    </table></form>
</body>

</html>
-- 
View this message in context: http://www.nabble.com/validation-problem-with-javascript-method-validateForm_Login%28%29-not-available-tf4081473.html#a11600614
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org