struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davout <dav...@dsl.pipex.com>
Subject Re: Struts 1.2 validation not working!
Date Sun, 01 Apr 2007 14:10:18 GMT

I downloaded the r1.2.7 release and used this as my comparison basis. My IDE
is 'MyEclipse' which uses a Struts 1.2 release.

The xml files are exactly the same. I used the 'beyond compare' file
comparison utility to view this, and there are no differences. .

What next?



Niall Pemberton-2 wrote:
> 
> Use the validation-rules.xml that comes with the version of Struts
> you're using. This exception usually happens when people upgrade their
> version of Struts but don't use the validation-rules.xml that ships
> with the new version.
> 
> Niall
> 
> On 3/29/07, davout <davout@dsl.pipex.com> wrote:
>>
>> I've added Struts validation to my application and I'm getting an
>> exception
>> when I try to use the 'required' validation type.
>>
>> Here's the code...
>>
>> The 'validation.xml' file...
>>
>> [Code]
>>
>>  <?xml version="1.0" encoding="UTF-8"?>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>  [/code]
>>
>> the start of the 'validation-rules.xml' file...
>>
>> [Code]
>>
>>
>>
>>
>>
>>
>>  [/code]
>>
>> the related action class...
>>
>> [Code]
>>  public class ImpactNegationEditAction extends
>> AbstractImpactNegationAction
>>        implements EntityIDs, ImpactNegationIDs {
>>
>>     public void save_onClick(FormActionContext aCtx) {
>>        ImpactNegationEditForm aForm = (ImpactNegationEditForm)
>> aCtx.form();
>>        aCtx.addErrors(aForm.validate(aCtx.mapping(),aCtx.request()));
>>        if (aCtx.hasErrors() == false) {
>>           // is add?
>>           if (aForm.getImpactNegationIDInt() == ID_UNASSIGNED) {
>>              // verify title is unique
>>              try {
>>                 ImpactNegation anOther =
>> getManager(aCtx).findByTitle(aForm.getTitle());
>>                 if (anOther != null) {
>>
>> addFieldError(aCtx,"title","error.duplicateField","Title");
>>                 }
>> [/code]
>>
>> the related form...
>>
>> [Code]
>>
>>  public abstract class AbstractSorForm extends FWValidatorForm {
>>  }
>>
>>  public class ImpactNegationEditForm extends AbstractSorForm {
>>
>>     private static final long serialVersionUID = 3604637580339030809L;
>>
>>     private String fImpactNegationID;
>>     private String fTitle;
>>     private String fDesc;
>>     private String fDisplayOrder;
>>     private String fPercent;
>>     private String fCaptionDetail = null;
>>     private String fFormTitle = null;
>>
>>     public ImpactNegationEditForm() {
>>        // TODO Auto-generated constructor stub
>>     }
>>
>>     public String getDesc() {
>>        return fDesc;
>>     }
>>
>>     public void setDesc(String aDesc) {
>>        fDesc = aDesc;
>>     }
>>
>>     public String getDisplayOrder() {
>>        return fDisplayOrder;
>>     }
>>     public int getDisplayOrderInt() {
>>        return Integer.parseInt(fDisplayOrder);
>>     }
>>
>>     public void setDisplayOrder(String aDisplayOrder) {
>>        fDisplayOrder = aDisplayOrder;
>>     }
>>
>>     public String getImpactNegationID() {
>>        return fImpactNegationID;
>>     }
>>
>>     public int getImpactNegationIDInt() {
>>        return Integer.parseInt(fImpactNegationID);
>>     }
>>
>>     public void setImpactNegationID(String aId) {
>>        fImpactNegationID = aId;
>>     }
>>
>>     public String getPercent() {
>>        return fPercent;
>>     }
>>     public double getPercentDouble() {
>>        return Double.parseDouble(fPercent);
>>     }
>>
>>     public void setPercent(String aPercent) {
>>        fPercent = aPercent;
>>     }
>>
>>     public String getTitle() {
>>        return fTitle;
>>     }
>>
>>     public void setTitle(String aTitle) {
>>        fTitle = aTitle;
>>     }
>>
>>     public String getCaptionDetail() {
>>        return fCaptionDetail;
>>     }
>>
>>     public void setCaptionDetail(String aCaptionDetail) {
>>        fCaptionDetail = aCaptionDetail;
>>     }
>>
>>     public String getFormTitle() {
>>        return fFormTitle;
>>     }
>>
>>     public void setFormTitle(String aFormTitle) {
>>        fFormTitle = aFormTitle;
>>     }
>>  }
>> [/code]
>>
>> the JSP body file...
>>
>> [Code]
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> [/code]
>>
>> the exception thrown...
>>
>> [Code:]
>>
>> the exception thrown when the form is validated...
>>  ERROR: 18:54:18: org.apache.struts.validator.ValidatorForm:
>> org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object,
>> org.apache.commons.validator.ValidatorAction,
>> org.apache.commons.validator.Field,
>> org.apache.struts.action.ActionMessages,
>> org.apache.commons.validator.Validator,
>> javax.servlet.http.HttpServletRequest)
>>  org.apache.commons.validator.ValidatorException:
>> org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object,
>> org.apache.commons.validator.ValidatorAction,
>> org.apache.commons.validator.Field,
>> org.apache.struts.action.ActionMessages,
>> org.apache.commons.validator.Validator,
>> javax.servlet.http.HttpServletRequest)
>>    at
>> org.apache.commons.validator.ValidatorAction.loadValidationMethod(ValidatorAction.java:627)
>>    at
>> org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:557)
>>    at org.apache.commons.validator.Field.validateForRule(Field.java:811)
>>    at org.apache.commons.validator.Field.validate(Field.java:890)
>>    at org.apache.commons.validator.Form.validate(Form.java:174)
>>    at org.apache.commons.validator.Validator.validate(Validator.java:367)
>>    at
>> org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:112)
>>    at
>> com.eis.sor.struts.action.impactnegation.ImpactNegationEditAction.save_onClick(ImpactNegationEditAction.java:84)
>>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>    at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>    at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>    at java.lang.reflect.Method.invoke(Method.java:585)
>>    at com.cc.framework.adapter.struts.ActionUtil.handleFormAction(Unknown
>> Source)
>>    at com.cc.framework.adapter.struts.FWAction.handleFormAction(Unknown
>> Source)
>>    at com.cc.framework.adapter.struts.ActionUtil.execute(Unknown Source)
>>    at com.cc.framework.adapter.struts.FWAction.execute(Unknown Source)
>>    at
>> com.eis.sor.struts.action.common.AbstractSorAction.execute(AbstractSorAction.java:30)
>>    at com.cc.framework.adapter.struts.FWAction.execute(Unknown Source)
>>    at
>> org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
>>    at
>> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
>>    at
>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
>>    at
>> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
>>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>> [/code]
>>
>>
>> Any ideas???
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Struts-1.2-validation-not-working%21-tf3484580.html#a9727581
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-1.2-validation-not-working%21-tf3484580.html#a9778069
Sent from the Struts - User mailing list archive at Nabble.com.


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


Mime
View raw message