> -----Original Message-----
> From: Marc Lustig [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 4:17 PM
> To: Turbine Users List
> Subject: AW: Intake question: how to add custum rule functions ?
>
>
>
> Thanks a lot Quinton for your suggestion. Could you give me
> some more advise please as neither the intake-howto nor the
> intake-service doc refer to the validator-attribute.
>
> > You could write a custom validator that would allow rules
> to be added
> > dynamically. Specify this in your intake group.
>
> So I just add the validator-attribute to the field-element like this
>
> <group key="kundendaten" name="KundendatenGroup"
> mapToObject="om.Kunde"> ...
> <field name="Ort" key="f" type="String"
> mapToObject="om.Kunde" mapToProperty="Ort" validator="ortval"/>
>
> and don't add any rule-element, right?
You are correct on the syntax. You can still add rules though.... The
idea here is that you are going to write a custom validator class which
will allow you to add rules to it. If your validator is a subclass of
DefaultValidator (like IntegerValidator, BooleanValidator, etc...) then
you will already have some default rules that you can use. There will
be no problem with addign a required rule and then dynamically adding a
custom rule to it.
Also there is no prebuilt interface for adding rules. You will have to
figure out how you will do this in your validator. The current
validators all have hard coded rules.
Out of curiousity, what sort of rules are you wanting to add
dynamically?
>
> > In order to access the validator, you must have access to the field
> > objects. You do this by using the intake tool to get the
> group which,
> > in turn, can give you the fields. Once you have the field,
> > field.getValidator() will give you your custom validator that you
> > specified in intake.xml.
>
> I can follow you so far:
> (in action-method)
> IntakeTool intake = (IntakeTool)context.get("intake");
> Group group = intake.get("KundendatenGroup","kundendaten");
> Field ort = group.get("Ort");
> Validator val = ort.getValidator();
>
> Now what do I do with the validator to validate the field?
All that you would do at this point is add your dynamic rules to the
validator.
> And where do I put the code for the actual validation?
Assuming that you inherit from DefaultValidator, your code would be in
doAssertValidity(). This would be called when you call
Group.isAllValid() or Field.validate().
>
> Greetings
>
> Marc
>
> > After you have added the dynamic rules to the appropriate
> fields, just
> > call group.isAllValid() as before.
>
>
>
> >
> > > -----Original Message-----
> > > From: Marc Lustig [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, January 15, 2003 8:40 AM
> > > To: Turbine Users List
> > > Subject: Intake question: how to add custum rule functions ?
> > >
> > >
> > > Hi,
> > >
> > > I need to do some validation on submitted form-fields
> that are not
> > > supported by any of the rule-elements. (E.g. I need to
> look up the
> > > value in a different table.)
> > >
> > > Has anybody successfully added custom rule-functions
> manually in the
> > > action-method, before calling intake.isAllValid() ?
> > >
> > > Actually, my idea is to extend TurbineIntakeService and
> add methods
> > > to validate form-fields individually. First problem is I
> can't see
> > > any methods in TurbineIntakeService to get the form-fields and to
> > > mark fields as un/validated (like setFieldAsValidated(String
> > > fieldname)).
> > >
> > > Any Intake-expert out there who can give me a hint?
> > >
> > > Marc
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <mailto:turbine-user-> [EMAIL PROTECTED]>
> > > For
> > > additional commands,
> > > e-mail: <mailto:[EMAIL PROTECTED]>
> > >
> > >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
> --
> To
> unsubscribe, e-mail:
> <mailto:turbine-user-> [EMAIL PROTECTED]>
> For
> additional commands,
> e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>