struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "j alex" <strutstwou...@gmail.com>
Subject Re: Conditional + visitor validation - for nested objects -- so far..
Date Mon, 13 Aug 2007 14:03:31 GMT
So far, i've been able to define the actual validation on the domain
attribute addressline1, by putting @VisitorFieldValidator on the setters of
all objects that contain it (ie application,primaryapp,address) . Now, i
need to restrict the validation depending on the method called within the
Action - these correspond to different buttons on the same page (ie same
Action) ; say if submitOne() is invoked, only addressline1 should be
validated ; and for submitTwo() ; addressline2 should be validated.

Since the domain object should not be tied to any Action in particular, i
also want the flexibility to validate addressline1 when called from another
Action, and the error message should be different in this case.

dunno if this is asking for too much, or there's something wrong the way i'm
thinking abt it!

-Joseph

On 8/11/07, j alex <strutstwouser@gmail.com> wrote:
>
> Hi Paul,
>
> Let me explain in detail : I have an application that needs to collect
> info about a primary applicant (applicant1) and one or more co-applicants
> (coapp1, coapp2 etc.) . So, we could be presenting the same fields from the
> domain model multiple times in the page - like :
>
> Primary App info :
> <s:textfield name="application.primaryApp.address.addressline1"../>
> <s:textfield name="application.primaryApp.address.addressline2"../>
>
> Co=App info :
> <s:textfield name="application.coApp1.address.addressline2"../>
> <s:textfield name="application.coApp1.address.addressline2"../>
>
> and the error message must be specific to the corresponding applicant.
> Also, the rules could be different for the co-apps than the primary apps.
>
> Address is the domain object having fields addressline1, addressline2 etc.
> and this could be tied to primaryapp or coapp. In the Action class, we have
> a getApplication and setApplication alone. Also, note that we show both of
> these in the same page, and the Action is the same.
>
> I want to use visitor validation here since the fields are the same and i
> don't want to repeat them N times, but just define it once in the model.
>
> In this case, where would we define the @VisitorFieldValidator and the
> field-specific validations (@EmailValidator,  @StringLengthFieldValidator
> etc.)
>
> Thanks,
> Joseph
>
> On 8/11/07, Paul Benedict <pbenedict@apache.org> wrote:
> >
> > So your error messages are customized based on user? That doesn't make
> > sense
> > to me. Are you sure?
> >
> > Paul
> >
> > On 8/10/07, j alex <strutstwouser@gmail.com> wrote:
> > >
> > > Hi All,
> > >
> > > This is somewhat related to Matt's post on conditional validation at
> > > http://www.nabble.com/Re:-Conditional-validation-p11990883.html ; i
> > dont
> > > have the original email on struts-user (joined the group only last
> > week!)
> > > to
> > > reply to :
> > >
> > > I need some help regarding the extent to which we can apply visitor
> > field
> > > validation. Say, my domain object (Address - with attributes
> > addrline1,
> > > addrline2, ZIP etc.) is buried deep in a hierarchy - ie
> > app.user1.address;
> > > and we define only "app" in the Action. Can we declare a visitor
> > > validation
> > > on "app" and define the  rules on Address-validation.xml ? .
> > >
> > > My requirement is that we could use address in different objects ;
> > like
> > > app.user1.address ; app.user2.address - and the error message needs to
> > > be customized
> > > depending on user1, user2 etc . It'll be elegant if the validation
> > rules
> > > are
> > > defined just once for Address. Right now, the only way i know to
> > achieve
> > > is
> > > to define ALL fields in the <action>- validation.xml and hardcode the
> > > message for each situation ; which i think is an overkill.
> > >
> > > Please let me know if you've any suggestions/ideas.
> > >
> > > Thanks,
> > > Joseph
> > >
> >
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message