struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Caroline Jen <jiapei_...@yahoo.com>
Subject Write Own Validation Instead of Using validation.xml
Date Tue, 12 Oct 2004 15:14:54 GMT
I am submitteing a form.  This form provides check
boxes for multiple selections.  I am not using the
validation.xml to validate if "none" is selected. 
Instead, I am going to use the validate().

1. Do I write this validate() in the form class that
extends the ActionForm?  

2. how do I write this validate() method?

3. Where does this 'ae' return to?


public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) 
{
   ActionErrors ae = new ActionErrors();

   if ????? 
   {
      ae.add( "???", new ActionError("a lable that
will be inserted into the application.properties
file"));
   }
   return ae;
}

My form class looks like:

import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

public class selectRecipientsForm extends ActionForm
{
    private Map recipientFieldMap = new HashMap();

    private String[] recipients = new String[0];

    public RecipientField getRecipients( int index )
    {
       RecipientField recipientField = (
RecipientField ) recipientFieldMap.get( new Integer(
index ) );
       if ( recipientField == null )
       {
         recipientField = new RecipientField();
         recipientFieldMap.put( new Integer( index ),
recipientField );
       }
       return recipientField;
    }

   public void reset( ActionMapping mapping,
HttpServletRequest request) 
   {
       recipients = new String[0];
   }
}


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Mime
View raw message