struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "zhouyanming (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4166) Allow "class" attribute on Struts tags
Date Mon, 04 Aug 2014 11:36:13 GMT

    [ https://issues.apache.org/jira/browse/WW-4166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14084555#comment-14084555
] 

zhouyanming commented on WW-4166:
---------------------------------

cache will improve 100x performance, and I rewrited your code, please check it.
Component.java
{code:java}
    /**
     * Checks if provided name is a valid tag's attribute
     *
     * @param attrName String name of attribute
     * @return true if attribute with the same name was already defined
     */
    public boolean isValidTagAttribute(String attrName) {
        return getStandardAttributes().contains(attrName);
    }

    /**
     * If needed caches all methods annotated by given annotation to avoid further scans
     */
    protected List<String> getStandardAttributes() {
        Class clz = getClass();
        List<String> standardAttributes = standardAttributesMap.get(clz);
        if (standardAttributes == null) {
            Collection<Method> methods = AnnotationUtils.getAnnotatedMethods(clz, StrutsTagAttribute.class);
            standardAttributes = new ArrayList<String>(methods.size());
            for(Method m : methods)
            	standardAttributes.add(StringUtils.uncapitalize(m.getName().substring(3)));
            standardAttributesMap.putIfAbsent(clz, standardAttributes);
        }
        return standardAttributes;
    }
    
    private static ConcurrentHashMap<Class, List<String>> standardAttributesMap
= new ConcurrentHashMap<Class, List<String>>();
{code}


> Allow "class" attribute on Struts tags
> --------------------------------------
>
>                 Key: WW-4166
>                 URL: https://issues.apache.org/jira/browse/WW-4166
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Other
>            Reporter: Eric Lentz
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.18
>
>
> In building a JSP, and working on web related things outside of the Java environment,
there are lots of tags which all receive the "class" attribute. The Struts developer must
_remember_ to call the attribute cssClass instead. Typing muscle memory drives me to half
of the time typing "class" instead, which leads to HTML which reads, 'class="class java.util.HashMap"'
> Why not just allow "class" like the rest of the HTML world? Why do we need to be different?
I have a billion things to remember when web developing, this shouldn't be one of them.
> We don't even have to to deprecate or obsolete cssClass, just also allow "class"... please!



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message