Sorry, those APIs are not in place yet. I have JIRA issue add
optional validators, which is a loose, general term for what you are
aiming for ("password is required if userName is given").
I think some relationships may not be expressable using the @Validate
annotation, i.e., the string representation; I'm thinking there will
be a kind of JavaScript template object that will be used to generate
some kinds of JavaScript.
Things have slowed down on 5.0 for a moment, while I work on an urgent
client project (in Tapestry 5).
On Tue, Mar 25, 2008 at 11:08 AM, Julian Wood <[EMAIL PROTECTED]> wrote:
> Not possible?
>
> Sometimes a validator needs to look at input from another field to see
> if it is valid (ie password/confirmPassword). I know it's easy to do
> in onValidateForm, but I'd like to see how to do it in a nice modular
> Validator. I'm looking for something like:
>
> public void validate(Field field, String sourceFieldId,
> MessageFormatter formatter, Object value) throws ValidationException {
> Component page = ((AbstractField) field)._resources.getPage();
> try {
> Method getter =
> page.getClass().getDeclaredMethod(getMethodName(sourceFieldId));
> String sourceValue = (String) getter.invoke(page);
> if (value == null || !value.toString().equals(sourceValue))
> throw new ValidationException(buildMessage(formatter,
> field));
> } catch (Exception e) {
> log.error("No public getter field in page for: " +
> sourceFieldId);
> }
> }
>
>
> but can't do that (the only problem being the private _resources). How
> can that be done in a Validator? I can't inject anything. I don't
> actually need to make my own field which exposes the
> ComponentResources, do I?
>
> Thanks.
>
> J
>
>
>
>
>
> On Mar 24, 2008, at 5:17 PM, Julian Wood wrote:
>
> > How can you get access to an arbitrary Field from inside a
> > Validator, given its id? In t4 it was relatively easy to grab the
> > form and from there grab a field.
> >
> > Thanks,
> >
> > J
> >
> > ---------------------------------------------------------------------
> > 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]
>
>
--
Howard M. Lewis Ship
Creator Apache Tapestry and Apache HiveMind
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]