You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by hu...@apache.org on 2006/11/22 21:45:48 UTC
svn commit: r478316 -
/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java
Author: husted
Date: Wed Nov 22 12:45:48 2006
New Revision: 478316
URL: http://svn.apache.org/viewvc?view=rev&rev=478316
Log:
WW-1491 Add setting to govern whether to force the initial letter of an action to lowercase.
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java?view=diff&rev=478316&r1=478315&r2=478316
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java Wed Nov 22 12:45:48 2006
@@ -89,6 +89,19 @@
private String defaultParentPackage = "struts-default";
/**
+ * The default page prefix (or "path").
+ * Some applications may place pages under "/WEB-INF" as an extreme security precaution.
+ */
+ private static final String FORCE_LOWER_CASE = "struts.configuration.classpath.forceLowerCase";
+
+ /**
+ * Whether to use a lowercase letter as the initial letter of an action.
+ * If false, actions will retain the initial uppercase letter from the Action class.
+ * (<code>view.action</code> (true) versus <code>View.action</code> (false)).
+ */
+ private boolean forceLowerCase = true;
+
+ /**
* Default suffix that can be used to indicate POJO "Action" classes.
*/
private static final String ACTION = "Action";
@@ -150,6 +163,9 @@
defaultPagePrefix = Settings.get(DEFAULT_PAGE_PREFIX);
}
+ if (Settings.isSet(FORCE_LOWER_CASE)) {
+ forceLowerCase = Settings.get(FORCE_LOWER_CASE).equalsIgnoreCase("true");
+ }
}
/**
@@ -293,8 +309,8 @@
actionName = actionName.substring(0, actionName.length() - ACTION.length());
}
- // Force initial letter of action to lowercase
- if (actionName.length() > 1) {
+ // Force initial letter of action to lowercase, if desired
+ if ((forceLowerCase) && (actionName.length() > 1)) {
int lowerPos = actionName.lastIndexOf('/') + 1;
StringBuilder sb = new StringBuilder();
sb.append(actionName.substring(0, lowerPos));
Re: svn commit: r478316 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java
Posted by Ted Husted <hu...@apache.org>.
Thanks. To get started, I just copied what was already there. I'll
come back to it when the other settings are refactored. Next, I wanted
to look into generating action mappings for eligible methods, so that
we can fix the "dynamic invocation" syntax.
On 11/22/06, Don Brown <mr...@twdata.org> wrote:
> Aren't we going to keep the settings defined in StrutsConstants? Also,
> you need to define a setter with an @Inject annotation for it to be
> populated. Don't use the Settings object, as it shouldn't be used
> anymore. In fact, it should even be viewable from that package as I
> made it package private....
>
> Don
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: svn commit: r478316 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java
Posted by Don Brown <mr...@twdata.org>.
Aren't we going to keep the settings defined in StrutsConstants? Also,
you need to define a setter with an @Inject annotation for it to be
populated. Don't use the Settings object, as it shouldn't be used
anymore. In fact, it should even be viewable from that package as I
made it package private....
Don
husted@apache.org wrote:
> Author: husted
> Date: Wed Nov 22 12:45:48 2006
> New Revision: 478316
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=478316
> Log:
> WW-1491 Add setting to govern whether to force the initial letter of an action to lowercase.
>
> Modified:
> struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java
>
> Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java
> URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java?view=diff&rev=478316&r1=478315&r2=478316
> ==============================================================================
> --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java (original)
> +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java Wed Nov 22 12:45:48 2006
> @@ -89,6 +89,19 @@
> private String defaultParentPackage = "struts-default";
>
> /**
> + * The default page prefix (or "path").
> + * Some applications may place pages under "/WEB-INF" as an extreme security precaution.
> + */
> + private static final String FORCE_LOWER_CASE = "struts.configuration.classpath.forceLowerCase";
> +
> + /**
> + * Whether to use a lowercase letter as the initial letter of an action.
> + * If false, actions will retain the initial uppercase letter from the Action class.
> + * (<code>view.action</code> (true) versus <code>View.action</code> (false)).
> + */
> + private boolean forceLowerCase = true;
> +
> + /**
> * Default suffix that can be used to indicate POJO "Action" classes.
> */
> private static final String ACTION = "Action";
> @@ -150,6 +163,9 @@
> defaultPagePrefix = Settings.get(DEFAULT_PAGE_PREFIX);
> }
>
> + if (Settings.isSet(FORCE_LOWER_CASE)) {
> + forceLowerCase = Settings.get(FORCE_LOWER_CASE).equalsIgnoreCase("true");
> + }
> }
>
> /**
> @@ -293,8 +309,8 @@
> actionName = actionName.substring(0, actionName.length() - ACTION.length());
> }
>
> - // Force initial letter of action to lowercase
> - if (actionName.length() > 1) {
> + // Force initial letter of action to lowercase, if desired
> + if ((forceLowerCase) && (actionName.length() > 1)) {
> int lowerPos = actionName.lastIndexOf('/') + 1;
> StringBuilder sb = new StringBuilder();
> sb.append(actionName.substring(0, lowerPos));
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org