are you using simple theme and struts 2.1.6 ? if yes you need to use tags s:fielderror and s:actionerror to display error
On Sun, Jun 21, 2009 at 8:45 PM, Sam Wun <swun2...@gmail.com> wrote: > Hi, > > I tried generate a validation.xml file with "form name", "field > property", "msg name", and "key" in the file, but it doesn't generate > these information in the file from the struts tags given in my > ActionForm java file. > > Here is the java soruce file I have: > > package com.XYZ.onlinepayment.portlet; > > import org.apache.struts.validator.ValidatorForm; > import javax.servlet.http.HttpServletRequest; > > import org.apache.struts.action.ActionErrors; > import org.apache.struts.action.ActionForm; > import org.apache.struts.action.ActionMapping; > import org.apache.struts.action.ActionMessage; > > /** > * Search query entry form. > * > * @struts.form name="OrderForm" > */ > public class OrderForm extends ActionForm{ > private String firstname=""; > private String lastname=""; > private String email_address=""; > private String phone_number=""; > private String shipping_address=""; > private String billing_address=""; > /** > * Sets the query attribute of the OrderForm object > * > * @struts.validator type="required" msgkey="error.firstname.required" > */ > public void setFirstName(String fn){ > this.firstname = fn; > } > public String getFirstName(){ > return this.firstname; > } > /* > * @struts.validator type="required" msgkey="error.lastname.required" > */ > public void setLastName(String ln){ > this.lastname = ln; > } > public String getLastName(){ > return this.lastname; > } > /* > * @struts.validator type="required" > msgkey="error.email_address.required" > */ > public void setEmailAddress(String email){ > this.email_address = email; > } > public String getEmailAddress(){ > return this.email_address; > } > /* > * @struts.validator type="required" > msgkey="error.shipping_address.required" > */ > public void setShippingAddress(String shipping) { > this.shipping_address = shipping; > } > public String getShippingAddress(){ > return this.shipping_address; > } > /* > * @struts.validator type="required" > msgkey="error.billing_address.required" > */ > public void setBillingAddress(String billing) { > this.billing_address = billing; > } > > public String getBillingAddress(){ > return this.billing_address; > } > /* > * @struts.validator type="required" msgkey="error.phone_number.required" > */ > public void setPhoneNumber(String ph) { > this.phone_number = ph; > } > public String getPhoneNumber(){ > return this.phone_number; > } > > public void reset(ActionMapping mapping, HttpServletRequest req) { > this.firstname=""; > this.lastname=""; > this.phone_number=""; > this.email_address=""; > this.shipping_address=""; > this.billing_address=""; > } > > .... > > > And I also tried to run Ant with "ant -Dform.name=OrderForm" and just > the "ant <ENTER>" command. It only genereated the following "empty" > validation.xml file: > # cat validation.xml > <?xml version="1.0" encoding="UTF-8" ?> > <!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD > Commons Validator Rules Configuration 1.1//EN" > "http://jakarta.apache.org/commons/dtds/validator_1_1.dtd"> > > <form-validation> > <!-- > Define global validation config in validation-global.xml > --> > <formset> > <!-- > Define form validation config in validation-forms.xml > --> > > </formset> > </form-validation> > > What is wrong with my setup? > > Thanks > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >