You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mallik <ma...@yahoo.com> on 2006/09/05 13:05:25 UTC

validation framework problem?

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#a6149898
Sent from the Struts - User forum at Nabble.com.


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


Re: validation framework problem?

Posted by Jorge Martín Cuervo <jo...@defactops.com>.
Hi

i used validator and i got problems with validWhen, i wrote validWhen
with caps and until i change to validwhen it didn't work properly.

Please send us the struts-config.xml or the <action> you use, maybe the
problem is there.


El mar, 05 de 09 de 2006 a las 13:05, Mallik escribió:

> 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

-- 
;-)
____________________________________
Jorge Martin Cuervo
Analista Programador

Outsourcing Emarketplace
deFacto Powered by Standards

email <jo...@defactops.com>
voz +34 985 129 820
voz +34 660 026 384
____________________________________

Re: validation framework problem?

Posted by Laurie Harper <la...@holoweb.net>.
Everything looks OK so far, based on a quick scan through. What does the 
rest of your login.jsp look like? In particular, what does your 
html:form tag look like and where is the html:javascript tag?

You specified staticJavascript="false", so where are you importing the 
static Javascript from? If you tell the tag not to generate it, you'll 
need to have something else do so.

L.

Mallik wrote:
> 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
>>
>>
> 


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


RE: validation framework problem?

Posted by "RoseIndia.net Help" <te...@roseindia.net>.
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:malli345@yahoo.com]
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




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


Re: validation framework problem?

Posted by Mallik <ma...@yahoo.com>.
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org