Results 1 to 2 of 2

Thread: problem facing while developing DynaValidationForm application

  1. #1
    Join Date
    Apr 2007
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem facing while developing DynaValidationForm application

    hi to all

    i am not getting the parameter values whlie dispalying the errors. i am providing all my code here can any one help me regarding this



    Form Bean class:URformBean.java
    Code:
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    import org.apache.struts.validator.*;
    
    public class URFormBean extends DynaValidatorForm
    {
    	public void reset(ActionMapping actionMapping,HttpServletRequest req)
    	{
    		System.out.println("reset called");
    		set("userName","UserName");
    		set("passOne","");
    		set("passTwo","");
    		set("age","");
    		set("email","email id");
    		System.out.println("reset end");
    	}
    }
    Action class:URAction.java

    Code:
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    
    public class URAction extends Action
    {
    	public ActionForward execute(ActionMapping actionMapping,ActionForm form,HttpServletRequest req,HttpServletResponse res)throws Exception
    	{
    		try
    		{
    					URFormBean ufb=(URFormBean)form;			
    		}
    		catch (Exception e)
    		{
    			System.out.println("error");
    		}
    
    //		System.out.println((String)ufb.get("userName"));
    		return actionMapping.findForward("ur");
    	}
    }
    Form: urform.jsp

    Code:
    <%@ taglib uri="/tags/struts-html" prefix="html"%>
    <html:html>
    	<head><title>User Registration Form</title></head>
    	<body><html:errors/>
    	<html:form action="ura.do">
    	<b>User Name:</b>
    	<html:text property="userName"/><br>
    	<b>Password:</b>
    	<html:password property="passOne"/><br>
    	<b>Re-password:</b>
    	<html:password property="passTwo"/><br>
    	<b>age:</b>
    	<html:text property="age"/><br>
    	<b>email:</b>
    	<html:text property="email"/><br>
    	<html:submit property="submit" value="Register"/>
    	</html:form>
    	</body>
    </html:html>
    and
    sucess page after sucessfully registered

    struts-config.xml

    Code:
     <form-beans>
    
    	<form-bean name="URForm" type="URFormBean">
    		<form-property name="userName" type="java.lang.String"/>
    		<form-property name="passOne" type="java.lang.String"/>
    		<form-property name="passTwo" type="java.lang.String"/>
    		<form-property name="age" type="java.lang.String"/>
    		<form-property name="email" type="java.lang.String"/>
    	</form-bean>
     </form-beans>
    
    	<action path="/ura" type="URAction" name="URForm" scope="request" input="/urform.jsp" validate="true">
    		<forward name="ur" path="/ur.jsp"/>
    	</action>
    validation.xml

    [code]

    <formset>
    <form name="URForm">
    <field
    property="userName"
    depends="required">
    <arg0
    name="required"
    key="userName"
    resourse="true"/>
    </field>
    <field
    property="passOne"
    depends="required">
    <arg0
    name="required"
    key="passOne"
    resourse="false"/>
    </field>
    <field
    property="passTwo"
    depends="required">
    <arg0
    name="required"
    key="passTwo"
    resourse="false"/>
    </field>
    <field
    property="age"
    depends="required,range">
    <arg0
    name="required"
    key="age"
    resourse="false"/>
    <arg0
    name="range"
    key="age"
    resourse="false"/>
    <arg1
    name="range"
    key="${var:min}"
    resourse="false"/>
    <arg2
    name="range"
    key="${var:max}"
    resourse="false"/>
    <var>
    <var-name>min</var-name>
    <var-value>25</var-value>
    </var>
    <var>
    <var-name>max</var-name>
    <var-value>50</var-value>
    </var>
    </field>
    <field
    property="email"
    depends="required,email">
    <arg0
    name="required"
    key="email"
    resourse="false"/>
    <arg0
    name="email"
    key="email"
    resurse="false"/>
    </field>
    </form>
    </formset>



    all the above are different source code and im not getting errors or exceptions
    can any one tell where i am doing mistakes


    regards

  2. #2
    Join Date
    Nov 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Did you get any resolution for problem ?

    I am facing similar kind of problem.

    Any help will be appreciated.

    Thanks,

    Yogesh

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •