click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Naoki Takezoe (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLK-789) SpringClickServlet injection fails if "Page" class name starts with two or more upper case letters
Date Thu, 19 Apr 2012 02:40:40 GMT

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

Naoki Takezoe commented on CLK-789:
-----------------------------------

Spring's AnnotationBeanNameGenerator generates the bean name for components which registered
by annotation using Introspector#decapitalize().
So SpringClickServlet#toBeanName() should use it instead of the current implementation.

Index: extras/src/org/apache/click/extras/spring/SpringClickServlet.java
===================================================================
--- extras/src/org/apache/click/extras/spring/SpringClickServlet.java	(revision 1308655)
+++ extras/src/org/apache/click/extras/spring/SpringClickServlet.java	(working copy)
@@ -18,6 +18,7 @@
  */
 package org.apache.click.extras.spring;
 
+import java.beans.Introspector;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -518,9 +519,7 @@
      * @return the class bean name
      */
     protected String toBeanName(Class<?> aClass) {
-        String className = aClass.getName();
-        String beanName = className.substring(className.lastIndexOf(".") + 1);
-        return Character.toLowerCase(beanName.charAt(0)) + beanName.substring(1);
+        return Introspector.decapitalize(aClass.getSimpleName());
     }
 
     // Package Private Inner Classes ------------------------------------------

                
> SpringClickServlet injection fails if "Page" class name starts with two or more upper
case letters
> --------------------------------------------------------------------------------------------------
>
>                 Key: CLK-789
>                 URL: https://issues.apache.org/jira/browse/CLK-789
>             Project: Click
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.0
>         Environment: Apache Tomcat 6.0.32 or 7.0.16. JRE 1.6.0_29 on Linux.
> Spring Framework 3.0.5.
>            Reporter: Andrea Cozzolino
>            Priority: Minor
>              Labels: spring
>
> I am using SpringClickServlet to integrate Click with Spring.
> Spring injection in "Page" classes works only if the class name starts with exactly one
upper case letter. 
> If I have a class "ABTestPage" (that extends org.apache.click.Page and that is a @Component)
when I try to use it, any @Resource is "null". If I rename the class to "AbTestPage", any
@Resource is correctly injected.
> The following simple project demonstrates the problem: https://bitbucket.org/andcoz/clickspringuppercasebug/

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message