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

James Chaplin commented on WW-5093:
-----------------------------------

Hello.

I spent some time trying out some interactive examples based on [~nikos]'s 
commentary, and tried to review some of the relevant code too.

Here is a summary of what I saw (using Struts 2.5.25) for a named var 
attribute's result value using examples on a test JSP:
 * s:text - The value is placed into Action scope and Request scope.
 * s:url - The value is placed into Action scope and Request scope.
 * s:set - The value is placed into the specified scope.  If no scope is 
provided, it defaults to Action scope.  For scope Action, the value is +also+ 
placed into the Page scope.

The examples above use EL syntax on the JSP with the form ${var name}, which 
can produce unexpected results when using the same var name in different tag 
types on the JSP.

If we use s:property to retrieve a result (instead of EL), it should always use 
the Action scope and provide consistent results, even when an s:iterator tag is 
involved.

When a s:url and s:set (with no scope specified) tag both use the same var name 
in an iterator, results are a bit weird with EL syntax ${var name}. The s:set 
tag will set a reference at Page scope, which has precedence, so even if the 
s:url tag is defined afterwards you will "see" the s:set tag's var result 
(unless you specify scope in the EL as well, using ${requestScope.var name}).

Adding some additional information to the tag documentation might help clarify 
how things behave (as was mentioned in the JIRA description).

It looks like there may one or two comment discrepancies in some of the 
components, so a review of those to make sure they are accurate might be 
helpful too.

As an aside, I could not track down the code for the s:text tag processing that 
puts the var value into the Request scope, but interactive testing indicates it 
does exist at that scope (when accessed by EL). If anyone can clarify how that 
happens it would be appreciated.

> inconsistent scope for variables created with s:set and s:url
> -------------------------------------------------------------
>
>                 Key: WW-5093
>                 URL: https://issues.apache.org/jira/browse/WW-5093
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Tags
>    Affects Versions: 2.5.22
>            Reporter: nikos dimitrakas
>            Priority: Major
>              Labels: scope, tag, var
>             Fix For: 2.6
>
>
> The implementation of s:set and s:url and s:text is not consistent and not 
> well documented. 
> Creating a variable with s:set puts the variable in a different default scope 
> than creating a variable with s:url or s:text (with the attribute var). It is 
> also not documented what the default scope is. After testing I could conclude 
> that the scope for a variable created by s:url is request, while the default 
> of s:set is not. Furthermore, s:set offers a possibility to specify the scope 
> with an attribute, But s:url and s:text do not. 
> Possible options would be offering the possibility to specify the scope 
> attribute in s:url and s:text, or dropping support for the var attribute for 
> s:url and s:text and only allow s:set to create variables (thus being forced 
> to nest s:url and s:text inside an s:set). That would be symmetric with how 
> s:property does not offer the var attribute. At minimum all three tags should 
> have the same default and their default should be explicitly specified in the 
> documentation (in the tld and the online manual / tag reference)



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

Reply via email to