History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: STS-351
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Tim Fennell
Reporter: Andy
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Stripes

Wrong key used to lookup field name in foo[1].bar[2].baz

Created: 27/Mar/07 06:08 AM   Updated: 01/Apr/07 02:20 PM
Component/s: Validation
Affects Version/s: Release 1.4.2
Fix Version/s: Release 1.4.3


 Description  « Hide
The field name for field "foo[1].bar[2].baz" should be obtained from key "foo.bar.baz" in StripesResources.properties. Currently, it is obtained from key "foo.baz".

In the following test case, entering "x" on the text field generates

Please fix the following errors:

   1. The value (x) entered in field Wrong must be a valid number

The expected message is "... in field Correct ..."

==> BarType.java <==
package com.myco.action;

public class BarType {
    private Integer baz;
    public Integer getBaz() { return baz; }
    public void setBaz(Integer baz) { this.baz = baz; }
}

==> FooType.java <==
package com.myco.action;

import java.util.*;

public class FooType {
    private Map<String, BarType> bar = new HashMap<String, BarType>();
    public Map<String, BarType> getBar() { return bar; }
    public void setBar(Map<String, BarType> bar) { this.bar = bar; }
}

==> TestAction.java <==
package com.myco.action;

import java.util.*;
import net.sourceforge.stripes.action.*;

public class TestAction implements ActionBean {
    private ActionBeanContext context;
    public ActionBeanContext getContext() { return context; }
    public void setContext(ActionBeanContext context) {
        this.context = context;
    }

    private Map<String, FooType> foo = new HashMap<String, FooType>();
    public Map<String, FooType> getFoo() { return foo; }
    public void setFoo(Map<String, FooType> foo) { this.foo = foo; }

    public Resolution nothing() {
        return getContext().getSourcePageResolution();
    }
}

==> StripesResources.properties <== (add these)
foo.baz=Wrong
foo.bar.baz=Correct

==> index.jsp <==
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<stripes:form beanclass="com.myco.action.TestAction">
    <stripes:errors/>
    <stripes:text name="foo[1].bar[2].baz"/>
    <stripes:submit name="nothing"/>
</stripes:form>

==> (end) <==

 All   Comments   Change History      Sort Order:
Tim Fennell [01/Apr/07 02:20 PM]
This turned out to be a simple fix. A regex is used to identify bracketed groups (e.g. [123]) and remove them from the property name. But a greedy quantifier was used so it matched that first opening and last closing bracket. Changing to a reluctant quantifier fixed it right up.