Bug Validation: error has bad fieldname for empty entity

25 views
Skip to first unread message

Cyrille37

unread,
Apr 13, 2011, 9:22:35 AM4/13/11
to play-framework

Hi,
Not easy to find a short way to explain the problem (bug ?).

It's about the edition of a list of object. In the view I put existing
list items and add some empty list items to facilitate the addition of
new items. I manage the state of those new object in the
contoller.save(). All stuff work fine except the field.name needed to
print errors.

For new items (Entity with no Id), the validation process change the
field name from the second new field, like :

p0 is an existing entity field, where p1 and p2 are not exists
entities, they were added by hand to the list before rendering.

p0.name: Minimum size is 2
p0: Validation failed
p1.name: Minimum size is 2
p1: Validation failed
p1.p2.name: Minimum size is 2
p2: Validation failed

See that p2.name become "p1.p2.name". So, the view could not retrieve
the p2's name field.

I've opened a ticket with a test case:
http://play.lighthouseapp.com/projects/57987-play-framework/tickets/726

Cheers
Cyrille

Cyrille37

unread,
Apr 13, 2011, 9:39:08 AM4/13/11
to play-framework
While debugging I've found:

in play.data.validation.ValidCheck.isSatisfied()
String superKey = ValidationPlugin.keys.get().get(validatedObject);
For p2 the superKey is "p1", so the fieldname for error will be
construct as "p1.p2" which is wrong.

So, with the debugger, I force "superKey" to "null", and it's work !
All error's fieldname are good.

Now I'll try to investigate inside
"ValidationPlugin.keys.get().get(validatedObject);"
...

Cyrille.

Cyrille37

unread,
Apr 13, 2011, 10:04:01 AM4/13/11
to play-framework
On 13 avr, 15:39, Cyrille37 <cyrill...@gmail.com> wrote:
> While debugging I've found:
>
> in play.data.validation.ValidCheck.isSatisfied()
>  String superKey = ValidationPlugin.keys.get().get(validatedObject);
> For p2 the superKey is "p1", so the fieldname for error will be
> construct as "p1.p2" which is wrong.
>
> So, with the debugger, I force "superKey" to "null", and it's work !
> All error's fieldname are good.


Perhaps the problem comes from that empty fields (p1 and p2) have the
same "Id" => 0 ?
But they have not the same reference ... computing becomes very
complex, isn't it ;-)

So, I've forced the "Id" with a fake one for each entity and all stuff
works fine. But indeed it's not a solution. That just confirms that
the "Id" is used to get the "validatedObject" in
"ValidationPlugin.keys".

How can I solve the problem ?

Is it a bug, or a bad Play! usage ?

Thanks
Cyrille
Reply all
Reply to author
Forward
0 new messages