[ 
https://issues.apache.org/jira/browse/WW-4164?focusedWorklogId=1051814&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1051814
 ]

ASF GitHub Bot logged work on WW-4164:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 02/Nov/26 08:09
            Start Date: 02/Nov/26 08:09
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart commented on code in PR #2093:
URL: https://github.com/apache/struts/pull/2093#discussion_r4440057172


##########
core/src/main/java/org/apache/struts2/components/Component.java:
##########
@@ -81,6 +82,10 @@ public static void clearStandardAttributesMap() {
     protected ValueStack stack;
     protected Map<String, Object> attributes;
     protected ActionMapper actionMapper;
+    /**
+     * @since 7.5.0
+     */
+    protected ActionExtensionResolver actionExtensionResolver;

Review Comment:
   Comment is useless, the same is already communicated with the setter below



##########
core/src/main/java/org/apache/struts2/config/entities/PackageConfig.java:
##########
@@ -321,6 +323,31 @@ public String getFullDefaultResultType() {
         return defaultResultType;
     }
 
+    /**
+     * @return extensions declared on this package, or null when it declares 
none
+     * @since 7.5.0
+     */
+    public List<String> getExtensions() {
+        return extensions;
+    }
+
+    /**
+     * @return extensions declared on this package, else on the first parent 
that declares them, else null
+     * @since 7.5.0
+     */
+    public List<String> getFullExtensions() {
+        if (extensions != null) {
+            return extensions;
+        }
+        for (PackageConfig parent : parents) {
+            List<String> parentExtensions = parent.getFullExtensions();
+            if (parentExtensions != null) {
+                return parentExtensions;
+            }
+        }
+        return null;

Review Comment:
   Why null instead of empty list?



##########
core/src/main/java/org/apache/struts2/config/entities/ActionConfig.java:
##########
@@ -130,6 +132,14 @@ public Set<HttpMethod> getHttpMethods() {
         return httpMethods;
     }
 
+    /**
+     * @return action extensions in declared order, null when neither the 
action nor its package declares any

Review Comment:
   null? Why not an empty list?





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1051814)
    Time Spent: 20m  (was: 10m)

> Improve support for multiple extensions
> ---------------------------------------
>
>                 Key: WW-4164
>                 URL: https://issues.apache.org/jira/browse/WW-4164
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: XML Configuration
>    Affects Versions: 2.3.15.1
>            Reporter: Jasper Rosenberg
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.5.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Currently if you support multiple extensions (eg. 
> struts.action.extension=action,html,,) there is no way to tell struts for a 
> particular action which extension you always want to use.  This has two 
> downsides:
> 1. When struts has to generate an url, for example in the form tag, or the 
> "redirectAction" result type, there is no way to specify the extension to 
> use, so it ends up using the current invocation's extension if possible, or 
> otherwise the default, neither of which might be correct.
> 2. You can invoke the action with any of the supported extensions, creating 
> duplicate pages with no clear canonical version.  (Bad for SEO as well)
> What I propose is allowing the user to specify an optional specific extension 
> at the package and action level in the struts xml configuration like so:
> {code:xml}
>   <package name="test" namespace="/" extends="default" extension="action">
>     <action name="a1" extension="">
>       <result>a1.ftl</result>
>     </action>
>     <action name="b1" extension="html">
>       <result>b1.ftl</result>
>     </action>
>     <action name="c1">
>       <result>b1.ftl</result>
>     </action>
>   </package>
> {code}
> 1. When selecting an extension when building an URL for an action, it would 
> first see if there was an extension to use at the action level.  If not it 
> would check the package level (including package inheritance).  If still no 
> specific extension, it would behave as it currently does.
> 2. When mapping an incoming URL to an action, the reverse will also hold.  If 
> the action or its package specify a specific extension, then the action can 
> only be matched if the URL has that extension.
> So in the above example, the following urls would be expected to work:
> 1. /a1 (action level no extension)
> 2. /b1.html (action level "html" extension)
> 3. /c1.action (no action level extension, using package level "action" 
> extension)
> However, an url like "/b1.action" will not match any actions because "action" 
> extension doesn't match the action's "html" extension.
> This change would be 100% backwards because if you don't specify any 
> extension attributes on the package or action, it falls back to the current 
> behavior.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to