HI,

Have a look at
http://www.roseindia.net/struts/struts_validator_framework.shtml

In this tutorial you will learn how to use Struts Validator Framework to
validate the user inputs on the client browser.

Regards
Deepak Kumar
http://www.roseindia.net


-----Original Message-----
From: Mallik [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 05, 2006 4:53 PM
To: user@struts.apache.org
Subject: Re: validation framework problem?



Hi friends
--------------------------------------
this is my Action Login.java
package com.pack1;

import org.apache.struts.action.*;
import javax.servlet.http.*;

public class Login extends Action
{
        public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
        {
                return mapping.findForward("find");
        }
}

-------------------------------------
this is my total struts-config.xml

<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";>
<struts-config>
        <form-beans>
        <!-- =========DynaActionForm Bean -->
                <form-bean name="LoginForm"
type="org.apache.struts.validator.DynaValidatorForm">
                        <form-property name="userId" type="java.lang.String"/>
                        <form-property name="password" type="java.lang.String"/>
                </form-bean>
        </form-beans>

        <action-mappings>
                <action path="/index" forward="/pages/index.jsp"/>

                <action path="/login"   type="com.artifacts.Login"
input="/pages/index.jsp" >
                        <forward name="find" path="/pages/login.jsp"/>
                </action>

                <action path="/loginVerify" name="LoginForm" scope="request"
validate="true" type="com.artifacts.LoginVerify" input="/pages/login.jsp">
                        <forward name="valid" path="/pages/welcome.jsp"/>
                        <forward name="invalid" path="/pages/login.jsp"/>
                </action>

                <action path="/logout" forward="/pages/logout.jsp"/>

                <action path="/collegeSetup"  type="com.artifacts.CollegeSetup">
                        <forward name="completed" 
path="/pages/viewCollege.jsp"/>
                        <forward name="notCompleted" 
path="/pages/setupCollege.jsp"/>
                </action>

        </action-mappings>

<!--application resources file-->
        <message-resources parameter="timeTableMessages"/>

<!-- ==========Data Source========== -->
        <data-sources>
                <data-source>
                        <set-property property="driverName"
value="oracle.jdbc.driver.OracleDriver"/>
                        <set-property property="url"
value="jdbc:oracle:thin:@172.23.162.200:arti"/>
                        <set-property property="user" value="aims"/>
                        <set-property property="password" value="aims"/>

                </data-source>
        </data-sources>

<!-- =========validator plugin=========== -->
        <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
                <set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
        </plug-in>


</struts-config>

-------------------------------------------
i hope this will help u in better
waiting for solutions and thanks inadvance
Mallik


Mallik wrote:
>
> HI Friends
> i am using validation framework with struts at fontend
> but the validation is not working properly
> first-time validation is taking place at server side ( displaying errors
> on window)
> second-time onwards it is taking place at client side (getting alert)
> why these all?
> this is my code:
> ------------------------------------------------------
> struts-config.xml
>
> <form-bean name="LoginForm"
> type="org.apache.struts.validator.DynaValidatorForm">
>       <form-property name="userId" type="java.lang.String"/>
>       <form-property name="password" type="java.lang.String"/>
> </form-bean>
> .......
> .....
> <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
> <set-property property="pathnames"
> value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
> </plug-in>
>
> ------------------------------------------------------
> validator.xml
>
> <form  name="LoginForm">
> <field property="userId" depends="required,minlength,maxlength">
> <arg0 key="label.userId" />
> <arg1 key="${var:minlength}" name="minlength" resource="false" />
> <var>
> <var-name>minlength</var-name>
> <var-value>4</var-value>
> </var>
> <arg2 key="${var:maxlength}" name="maxlength" resource="false"/>
> <var>
> <var-name>maxlength</var-name>
> <var-value>10</var-value>
> </var>
> </field>
> <field property="password" depends="required,minlength,maxlength">
> <arg0 key="label.password"/>
> <arg1 key="${var:minlength}" name="minlength" resource="false" />
> <var>
> <var-name>minlength</var-name>
> <var-value>4</var-value>
> </var>
> <arg2 key="${var:maxlength}" name="maxlength" resource="false"/>
> <var>
> <var-name>maxlength</var-name>
> <var-value>10</var-value>
> </var>
> </field>
> </form>
> ------------------------------------------------------------
> resources.properties file
>
> #validator errors
> errors.required = {0} is required.
> errors.minlength = {0} cann't be less than {1} characters.
> errors.maxlength = {0} cann't be more than {2} characters.
> errors.invalid = {0} is invalid.
>
> # -- Label messages --
> label.userId = User ID
> label.password = Password
> ----------------------------------------------------------------
> login.jsp file
>
> <html:javascript formName="LoginForm" dynamicJavascript="true"
> staticJavascript="false" />
>
> and i didn't change anything in validation-rules.xml
>
>
> please let me know where i went worng
>
> Mallik
>
>

--
View this message in context:
http://www.nabble.com/validation-framework-problem--tf2220180.html#a6150067
Sent from the Struts - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to