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

Pierre-Yves Soblet commented on WW-5086:
----------------------------------------

Before applying the patch, the behavior was as follows: if there is no *value* 
attribute and the tag body is empty, the variable is set to the top object of 
the current context. However, this behavior is undocumented (to the best of my 
knowledge). Moreover, it breaks the assumption that the variable is either 
evaluated from the *value* expression or the tag body.

The purpose of the patch was to properly handle cases such as the following 
fragment:
{code:java}
<s:set var="someVariable"><x:otherTagLib .../></s:set>{code}
In this situation, I would expect the transfer of the output of the 
"otherTagLib" to the variable *someVariable*. However, if, in a specific 
context, the "otherTagLib" generates an empty output, *someVariable* is 
assigned to the top object (such as the Action instance), which makes no sense 
in this context.

Indeed, the patch breaks the test method *testStrutsScope2* but I am not sure 
this test is meaningful (other than demonstrating that the patch might break 
existing code that relies on this undocumented behavior). Maybe it should be 
explained in the migration guide for fixed versions (2.5.24, 2.6) (or if the 
old behavior is really the expected one, it should be documented) ?

Note that it is still possible to set the top object value explicitly through 
<s:set var="someVariable" value="top"/> if needed.

> s:set with empty body
> ---------------------
>
>                 Key: WW-5086
>                 URL: https://issues.apache.org/jira/browse/WW-5086
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Tags
>    Affects Versions: 2.5.22
>            Reporter: Pierre-Yves Soblet
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 2.5.24, 2.6
>
>         Attachments: 20200814_WW-5086.patch
>
>
> In Struts 2.5.22, the following JSP fragment:
> {code:java}
> <s:set var="myVariable"> </s:set>
> <s:property value="#myVariable"/>
> {code}
> generates the following HTML fragment:
> {code:java}
> com.sample.MyAction@c1a47f6c 
> {code}
> I would expect an empty output (as {{trimBody}} is set to "true" by default).
>  
> Moreover, when the {{set}} tag body is empty:
> {code:java}
> <s:set var="myVariable" trimBody="false"/>
> <s:property value="#myVariable"/>
> {code}
> disregarding the value of the {{trimBody}} attribute, the output is the same:
> {code:java}
> com.sample.MyAction@c1a47f6c
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to