Lukasz Lenart created WW-5782:
---------------------------------

             Summary: Anchor tag silently drops nested param tags when href is 
set
                 Key: WW-5782
                 URL: https://issues.apache.org/jira/browse/WW-5782
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - Tags
            Reporter: Lukasz Lenart


When {{<s:a>}} has an explicit {{href}} attribute, nested {{<s:param>}} tags 
are ignored and never appear in the rendered link. They are only used when the 
URL is built from the {{url}}-tag attributes ({{value}}, {{action}}, 
{{namespace}}, ...).

The main example in the {{Anchor}} javadoc shows exactly this combination, so 
it suggests behaviour the tag does not have:

{code}<s:a id="link1" href="/do-it.action">
    <img border="none" src="<%=request.getContextPath()%>/images/delete.gif"/>
    <s:param name="id" value="1"/>
</s:a>
{code}

h3. Observed

Same nested param, different way of giving the target:

||Tag||Rendered||
|{{<s:a href="/do-it.action">}} with {{<s:param name="id" value="1"/>}}|{{<a 
href="/do-it.action"></a>}}|
|{{<s:a value="/do-it.action">}} with {{<s:param name="id" value="1"/>}}|{{<a 
href="/do-it.action?id=1"></a>}}|

Reproduced on {{main}} (7.5.0-SNAPSHOT) with {{AnchorTagTest}}-style tests 
using {{ParamTag}}.

h3. Cause

In {{Anchor.evaluateExtraParams()}} the {{href}} branch only evaluates the 
{{href}} expression; the parameters collected from nested {{<s:param>}} tags 
({{urlParameters}}) are consumed only by the {{else}} branch that renders a URL 
through {{UrlRenderer}}. No existing test covers {{href}} together with nested 
params ({{AnchorTagTest#testAddParameters}} sets an {{href}} but adds no 
params).

h3. Expected

Either nested params are appended to an explicit {{href}}, or the combination 
is documented as unsupported and the javadoc example is corrected. Silently 
dropping them is the one outcome that should not stay.

Related: WW-3571 (rendering of {{<s:a>}} without any {{href}} or URL 
attributes) touches the same method.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to