aspose file tools*
The moose likes Struts and the fly likes problem in Struts Declerative validations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem in Struts Declerative validations" Watch "problem in Struts Declerative validations" New topic
Author

problem in Struts Declerative validations

ash sangy
Greenhorn

Joined: Jul 09, 2011
Posts: 6
plase help is there any problem with my validation.xnl file ,i have using struts1.3.8


Srruts-config.xnl


<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">


<struts-config>
<form-beans>
<form-bean name="loginform" type="com.myapp.struts.LoginForm"/>
<form-bean name="regform" type="com.myapp.struts.RegistrationForm"/>
</form-beans>

<global-exceptions>

</global-exceptions>

<global-forwards>
<forward name="welcome" path="/Welcome.do"/>
</global-forwards>

<action-mappings>
<action name="loginform" path="/login" type="com.myapp.struts.LoginAction" validate="true" input="/login.jsp">
<forward name="home" path="/home.jsp"/>
</action>
<action name="regform" path="/reg" type="com.myapp.struts.RegistrationAction" validate="true" input="/home.jsp">
<forward name="success" path="/success.jsp"/>
<forward name="failure" path="/failure.jsp"/>
</action>

</action-mappings>


<message-resources parameter="com/myapp/struts/ApplicationResource"/>

<!-- ========================= Tiles plugin ===============================-->
<!--
This plugin initialize Tiles definition factory. This later can takes some
parameters explained here after. The plugin first read parameters from
web.xml, thenoverload them with parameters defined here. All parameters
are optional.
The plugin should be declared in each struts-config file.
- definitions-config: (optional)
Specify configuration file names. There can be several comma
separated file names (default: ?? )
- moduleAware: (optional - struts1.1)
Specify if the Tiles definition factory is module aware. If true
(default), there will be one factory for each Struts module.
If false, there will be one common factory for all module. In this
later case, it is still needed to declare one plugin per module.
The factory will be initialized with parameters found in the first
initialized plugin (generally the one associated with the default
module).
true : One factory per module. (default)
false : one single shared factory for all modules
- definitions-parser-validate: (optional)
Specify if xml parser should validate the Tiles configuration file.
true : validate. DTD should be specified in file header (default)
false : no validation

Paths found in Tiles definitions are relative to the main context.
-->

<!-- ========================= 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>

Validation.xml:


<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

<form-validation>



<formset>

<!-- An example form -->
<form name="regform">
<field property="fname" depends="required">
<arg0 key="fname" resource="true"/>
</field>
<field property="lname" depends="required">
<arg0 key="lname" resource="true"/>

</field>
<field property="father" depends="required">
<arg0 key="father" resource="true"/>

</field>
<field property="g1" depends="required">
<arg0 key="gender" resource="true"/>

</field>
<field property="address" depends="required">
<arg0 key="address" resource="true" />

</field>
<field property="dob" depends="required,date">
<arg0 key="dob" resource="false" />
<var>
<var-name>datepatternstrict</var-name>
<var-value>dd-mm-yyyy</var-value>
</var>
</field>
<field property="phone" depends="required,mask">
<arg0 key="phone" resource="false"/>

<var>
<var-name>mask</var-name>
<var-value>^\d{2}-\d{10}*$</var-value>
</var>
</field>
<field property="pin" depends="required,mask">
<arg0 key="pin" resource="false"/>

<var>
<var-name>mask</var-name>
<var-value>^[0-9]$</var-value>
</var>
</field>
</form>

</formset>

<!-- An example formset for another locale
<formset language="fr">

<constant>
<constant-name>postalCode</constant-name>
<constant-value>^[0-9a-zA-Z]*$</constant-value>
</constant>

An example form
<form name="logonForm">
<field
property="username"
depends="required">
<arg key="logonForm.username"/>
</field>
<field
property="password"
depends="required,mask">
<arg key="logonForm.password"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>

</formset>-->

</form-validation>


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in Struts Declerative validations