This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

DynaAction and validation

Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to validate using the Validator frame work and try to avoid the ActionForm.
The page is not getting validated
Can You Help me out
Here is the code:
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<title>Example of a standard Customer form</title>
<h1>Example of a standard Customer form</h1>
<html:form action="/">
Last Name: <html:text property="lastName"/>
<html:errors property="lastName" /><br>
First Name: <html:text property="firstName"/>
<html:errors property="firstName" /><br>
Street Addr: <html:text property="street"/>
<html:errors property="street" /><br>
City: <html:text property="city"/>
<html:errors property="city" /><br>
State: <html:text property="state" maxlength="2" size="2" />
<html:errors property="state" /><br>
Postal Code: <html:text property="postalCode" maxlength="5" size="5" />
<html:errors property="postalCode" /><br>
Telephone: <html:text property="phone" maxlength="11" size="11" />
<html:errors property="phone" /><br>
Plug-in in included

<form-bean name="dynaCustomerForm"
<form-property name="lastName" type="java.lang.String"/>
<form-property name="firstName" type="java.lang.String"/>
<form-property name="street" type="java.lang.String" />
<form-property name="city" type="java.lang.String"/>
<form-property name="state" type="java.lang.String"/>
<form-property name="postalCode" type="java.lang.String"/>
<form-property name="phone" type="java.lang.String"/>

<action path="/addCustomer"
<forward name="success" path="/addCustomerSucceeded.jsp"
redirect="false" />
import org.apache.struts.action.*;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionForm;
import org.apache.struts.validator.DynaValidatorForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
public class AddCustomerAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{

DynaValidatorForm custForm =(DynaValidatorForm)form;

System.out.println("lastName = " + custForm.get("lastName"));
System.out.println("firstName = " + custForm.get("firstName"));
System.out.println("street = " + custForm.get("street"));
System.out.println("city = " + custForm.get("city"));
System.out.println("state = " + custForm.get("state"));
System.out.println("postalCode = "
+ custForm.get("postalCode"));
System.out.println("phone = " + custForm.get("phone"));
return mapping.findForward("success");

<form name=dynaCustomerForm >
depends="required" >
<arg0 key="dynaCustomerForm.lastName.label" />
depends="required" >
<arg0 key="dynaCustomerForm.firstName.label" />
depends="required" >
<arg0 key="dynaCustomerForm.street.label" />

depends="required" >
<arg0 key=””/>
<arg0 key=”dynaCustomerForm.state.label”/>
<arg0 key=”dynaCustomerForm.postalCode.label”/>
depends=”required,mask ”>
<arg0 key=”dynaCustomerForm.workPhone.label ”/>
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the validator enabled in your struts-config.xml? The configuration looks similar to this:
Abhay Kumar
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, I have enabled the plug-in.
But even then I am unable to get the result
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!