> The second form requires that you have some code like the following
in
> an action
>
> Field fieldA = intake.getGroup(...).getField(...);
> Field fieldB = ...
>
> if (fieldA.isSet())
> fieldB.setRequired(true);
>
> if (intake.isAllValid())
> ...
Ah, cool. That was one of my interpretations of what the
required-message was after reading your previous post, but I disregarded
it as I think the default-message concept would be more useful.
I haven't run into a case where fields could be conditionally required.
But couldn't it be done like:
if (fieldA.isSet() && !fieldB.isSet())
... handle not being set
You could make the point that with the required-message, you keep the
text in the intake config file, which is fine, but the functionality is
hard-coded for required-message and not extensible for other types of
messages. E.g.:
<field ...>
<rule ... />
<message name="required">this was an old required-message</message>
<message name="other">but now we can put other, general stuff
here</message>
</field>
Then do something like:
if (fieldA.isSet() && !fieldB.isSet())
print fieldB.getMessage("required")
else if (otherBusinessRuleIsInvalid)
print fieldB.getMessage("other")
If Intake gets refactored into Plexus, I'd lobby for the more
generalized message element to be used instead of required-message.
Thanks for taking the time to explain it to me,
Stephen
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>