Tim,

To me, this seems like a simple validation method and a field-level
validation in your action:

@Validate( required = "true" )
private String prospectcode;

@Validate( on="whatever" )
public void validatePostCodeAndLastName( ValidationErrors errors )
{
   if ( postcode == null && lastname == null )
   {
      errors.add( new SimpleError( "postcode or lastname must be provided.") );
   }
   else if ( postcode != null && lastname != null )
   {
      errors.add( new SimpleError( "Please provide either postcode or
lastname -- not both." ) );
   }
}

-- Rick

On Wed, Apr 7, 2010 at 8:35 AM, Stone, Timothy <tst...@barclaycardus.com> wrote:
> List,
>
>
>
> (Sorry for the premature send… not enough coffee this morning)
>
>
>
> I have an action that has 3 fields:
>
>
>
> prospectcode
>
> postcode
>
> lastname
>
>
>
> The form that is bound to this action will only have 2 fields (both required
> when present on the form):
>
>
>
> prospectcode
>
>
>
> and one (1) of
>
>
>
> ‘lastname’ OR ‘postcode’
>
>
>
>
>
> If ‘postcode’ is not present on the form, but ‘lastname’ is, how can the
> action ignore ‘postcode’ and return an error for ‘lastname’ only, i.e., if
> it is blank?
>
>
>
> Do I need to inspect the request parameters for the absence of one and the
> presence of the other, ‘postcode’ is null so ignore, and ‘lastname’ is blank
> (length returns 0). Though I have a gut feeling that Stripes intuitively
> handles this in the binding of form to action and there is something I’m
> missing about the annotations available in Stripes I’m not taking advantage
> of.
>
>
>
> Regards,
>
> Tim
>
>
>
>
>
>
> _______________________________________________________
>
> Barclays
> www.barclaycardus.com
> _______________________________________________________
>
> This e-mail and any files transmitted with it may contain confidential
> and/or proprietary information. It is intended solely for the use of the
> individual or entity who is the intended recipient. Unauthorized use of this
> information is prohibited. If you have received this in error, please
> contact the sender by replying to this message and delete this material from
> any system it may be on.
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to