Stripes

auto focus on error - map fields

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.5
  • Fix Version/s: None
  • Component/s: Tag Library
  • Labels:
    None

Description

Auto focus on error does not work for map fields.

For example,
<stripes:text name="fieldMap[field1]"/>

And in the ActionBean,

@ValidateNestedProperties( {
@Validate(field="field1", required=true)
})
private Map<String, String> fieldMap;

Validation works as expected. But the auto focus doesn't work and i see the following in the logs.

SEVERE: Form with action [/test/Test.action] has 'focus' set to '', but did not find a field with matching name to set focus on.

Stepping through the code in the IDE showed that the "setFocusOnFieldIfRequired" method in FormTag class doesn't find the field because the field name in the Validation error is "fieldMap.field1" ( vs "fieldMap[field1]" in the Form/JSP ).

Shouldn't the original field name be preserved ?

Activity

Hide
Ram added a comment - 02/Dec/08 12:25 AM

i originally thought that validation worked...It doesn't. I always get the "field is required" message.. even if i enter a value.

Does validation work for Map fields ? How do you specify validation for map fields ?

Show
Ram added a comment - 02/Dec/08 12:25 AM i originally thought that validation worked...It doesn't. I always get the "field is required" message.. even if i enter a value. Does validation work for Map fields ? How do you specify validation for map fields ?
Hide
Ben Gunter added a comment - 19/Dec/08 10:20 PM

The field names don't match because you used fieldMap[field1] in your JSP, and Stripes comes up with the field name from the @Validate(field="field1") by appending a dot and then the field name to the field name to which the nested @Validate applies. In this case, fieldMap.field1. I don't know if you'll have any luck using nested validation against a map key, but you should at least change your property name in the JSP to fieldMap.field1 instead of fieldMap[field1].

Show
Ben Gunter added a comment - 19/Dec/08 10:20 PM The field names don't match because you used fieldMap[field1] in your JSP, and Stripes comes up with the field name from the @Validate(field="field1") by appending a dot and then the field name to the field name to which the nested @Validate applies. In this case, fieldMap.field1. I don't know if you'll have any luck using nested validation against a map key, but you should at least change your property name in the JSP to fieldMap.field1 instead of fieldMap[field1].

People

  • Assignee:
    Unassigned
    Reporter:
    Ram
Vote (0)
Watch (1)

Dates

  • Created:
    27/Nov/08 12:38 AM
    Updated:
    19/Dec/08 10:20 PM