Hello,
when Tapestry renders components, or page, it checks for same form names, and if it sees say two forms named "abc", it names second one: "abc_0", and so on. The problem i stumbled on, that if i have two forms "abc" and "Abc", Tapestry leaves them the same. This causes in unexpected behaviour with IE (FF is ok), with clientSideValidation turned on. The problem was rather easy to stumble on, because i named some of my forms, with simplest name: "form". Others i did not name, so i ended up with "form" and "Form" in one page. The fix is of course trivial, but since i spent some time figuring this out, i was hoping to save someone else's time and maybe this could be fixed in code?

I looked in the code, a quick fix could be in org.apache.tapestry.util.IdAllocator:


change

private static class NameGenerator  {
        private final String _baseId;
        private int _index;
        NameGenerator(String baseId)  {
            _baseId = baseId + SEPARATOR;
        }
        public String nextId()  {
            return _baseId + _index++;
        }
    }

to:

private static class NameGenerator  {
        private int _index;
        public String nextId(String baseId)  {
            return baseId + SEPARATOR + _index++;
        }
    }

and

public String allocateId(String name)  {
        String key = name + _namespace;
        NameGenerator g = (NameGenerator) _generatorMap.get(key);
        String result = null;
        if (g == null) {
            g = new NameGenerator(key);
            result = key;
        } else
            result = g.nextId();
// Handle the degenerate case, where a base name of the form "foo$0" has been
        // requested. Skip over any duplicates thus formed.
        while (_generatorMap.containsKey(result))
            result = g.nextId();
        _generatorMap.put(result, g);
        return result;
    }

to:

public String allocateId(String name)  {
        String key = name + _namespace;
NameGenerator g = (NameGenerator) _generatorMap.get(key.toLowerCase());
        String result = null;
        if (g == null) {
            g = new NameGenerator();
            result = key;
        } else
            result = g.nextId(key);
// Handle the degenerate case, where a base name of the form "foo$0" has been
        // requested. Skip over any duplicates thus formed.
        while (_generatorMap.containsKey(result))
            result = g.nextId(key);
        _generatorMap.put(result.toLowerCase(), g);
        return result;
    }


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to