You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Jürgen Hoffmann <jh...@byteaction.de> on 2004/12/08 17:20:44 UTC
turbine 2.3.1 intake service
Hi,
is there any special reason why the DefaultValidator for Fields only
gets instantiated if there is one or more rules?
Kind regards
Juergen Hoffmann
Re: AW: turbine 2.3.1 intake service
Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
=?iso-8859-1?Q?J=FCrgen_Hoffmann?= <jh...@byteaction.de> writes:
>Hi all again,
>The Code Snippet is here
>http://jakarta.apache.org/turbine/turbine/turbine-2.3.1/xref/org/apache/turb
>ine/services/intake/model/Field.html#201
That might look like a bug. However, this is the behaviour since day
one. From looking at the code, the behaviour is even reasonable. :-)
- If you put a validator into the intake.xml file, it is used:
String validatorClassName = field.getValidator();
- If no user defined validator exists _and_ rules are available,
then use the default validator
if (validatorClassName == null && field.getRules().size() > 0)
{
validatorClassName = getDefaultValidator();
}
=> So the solution for you would be to explicitly state the default
validator (org.apache.turbine.services.intake.validator.BooleanValidator)
in the XML file.
Does the current behaviour make sense? Depends on where you are
looking. If we drop this statement, every field _will_ get a validator
even if it has no rules. So we must review the validators that they
behave like "no validator" in case no rules are around. I prefer to
keep it the way it is unless you come up with a really good reason. I
admit that it is some kind of "gotcha" with regards to Boolean fields.
Regards
Henning
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire
Linux, Java, perl, Solaris -- Consulting, Training, Development
What is more important to you...
[ ] Product Security
or [ ] Quality of Sales and Marketing Support
-- actual question from a Microsoft customer survey
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
AW: turbine 2.3.1 intake service
Posted by Jürgen Hoffmann <jh...@byteaction.de>.
Hi all again,
The Code Snippet is here
http://jakarta.apache.org/turbine/turbine/turbine-2.3.1/xref/org/apache/turb
ine/services/intake/model/Field.html#201
The Reason is the following. If you have a field of type Boolean for
example. One would assume that a BooleanValidator would be instantiated as a
Validator, no matter if I put in a rule or not. But unless I put in a rule
of the type
<rule name="required" value="false">ValidValue</rule>
This is not the case, and a Validator of type new Boolean(stringValue); is
instantiated byte getBoolean here:
http://jakarta.apache.org/turbine/turbine/turbine-2.3.1/xref/org/apache/turb
ine/services/intake/model/BooleanField.html#146
So if you put something like this inside your form which is perfectly
working if you have the above rule inside your field ...
<input type="checkbox" value="1" name="$intake.myboolean.key"
#if($intake.myboolean.value) checked#end/>
Will not work if you leave the rules out. Then you would have to write
<input type="checkbox" value="true" name="$intake.myboolean.key"
#if($intake.myboolean.value) checked#end/>
Since the Boolean Creator only accepts true everything else is false and the
BooleanValidator accepts 1,true,t,y,yes for true and false,f,no,n,0 for
false.
I am really wondering if the Behaviour now is desired as is...
Kind regards
Jürgen Hoffmann
-----Ursprüngliche Nachricht-----
Von: Jürgen Hoffmann [mailto:jh@byteaction.de]
Gesendet: Mittwoch, 8. Dezember 2004 17:21
An: turbine-dev@jakarta.apache.org
Betreff: turbine 2.3.1 intake service
Hi,
is there any special reason why the DefaultValidator for Fields only
gets instantiated if there is one or more rules?
Kind regards
Juergen Hoffmann
!EXCUBATOR:41b72a1a44709411119944!
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org