Validation Failed error message

2003-09-18 Thread Mehran Zonouzi
I get a 'Validation Failed' error message when I run my code...
I suspect that my naming convention for the getters and setters methods in my 
ActionForm class may not be
correct...

I think it is the contactId param that must be causing the problem.
What should the getters and setters for contactId be called?

// This is my ActionForm class

package com.db.gcp.lemweb.blotter.contacts;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;

//---
// Author: Mehran Zonouzi
// Date: 15/09/2003
// Purpose: This bean saves the param values that are to be
//  used with the EditContactAction class
//

public final class EditContactForm extends ActionForm {

   private String page = null;
   private String contactId = null;


// The usual getter and setter methods for beans

  public String getContactId(){
return (this.contactId);
  }

  public void setContactId(String contactId){
this.contactId = contactId;
  }

  public String getPage(){
return (this.page);
  }

  public void setPage(String page){
this.page = page;
  }

  // This method performs the form validation
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
 ActionErrors errors = new ActionErrors() ;

 if ( page == null || .equals(page)){
   errors.add(page, new ActionError(error.page));
 }

 if ( contactId == null || .equals(contactId)){
   errors.add(contactid, new ActionError(error.contactid));
 }

 return errors;
  }
}




--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Validation Failed error message

2003-09-18 Thread Sgarlata Matt
I'm not sure I understand the problem here, can you send the full error
message you are receiving?

Your getters and setters are correct for the contactId parameter.  FYI here
are some useful links for more information about correct JavaBeans naming
conventions.
http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils/package-summary.html#overview
(this is documentation for the beanutils subproject in commons, look at the
bullets)
http://java.sun.com/products/javabeans/docs/spec.html

One thing that does look suspicious is this line of code from your validate
method:

errors.add(contactid, new ActionError(error.contactid));

I would guess you should be doing

errors.add(contactId, new ActionError(error.contactid));

note that contactId is not contactid.

Matt
- Original Message - 
From: Mehran Zonouzi [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 5:11 AM
Subject: Validation Failed error message


 I get a 'Validation Failed' error message when I run my code...
 I suspect that my naming convention for the getters and setters methods in
my ActionForm class may not be
 correct...

 I think it is the contactId param that must be causing the problem.
 What should the getters and setters for contactId be called?

 // This is my ActionForm class

 package com.db.gcp.lemweb.blotter.contacts;

 import javax.servlet.http.HttpServletRequest;
 import org.apache.struts.action.*;


//--
-
 // Author: Mehran Zonouzi
 // Date: 15/09/2003
 // Purpose: This bean saves the param values that are to be
 //  used with the EditContactAction class

//--
--

 public final class EditContactForm extends ActionForm {

private String page = null;
private String contactId = null;


 // The usual getter and setter methods for beans

   public String getContactId(){
 return (this.contactId);
   }

   public void setContactId(String contactId){
 this.contactId = contactId;
   }

   public String getPage(){
 return (this.page);
   }

   public void setPage(String page){
 this.page = page;
   }

   // This method performs the form validation
   public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request){
  ActionErrors errors = new ActionErrors() ;

  if ( page == null || .equals(page)){
errors.add(page, new ActionError(error.page));
  }

  if ( contactId == null || .equals(contactId)){
errors.add(contactid, new
ActionError(error.contactid));
  }

  return errors;
   }
 }




 --

 This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]