struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruce Phillips (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4194) Using findValue() for value stack to retrieve component parameters always returns not-null object for any parameter name
Date Fri, 20 Sep 2013 16:09:53 GMT

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

Bruce Phillips commented on WW-4194:
------------------------------------

I was able to duplicate the problem using the attached project.  It appears using the Struts
2 component tag and a Struts 2 version after 2.3.14.3 will cause the problem. 

NOTE that the ValueStack method findValue when used within an Action class continues to work
correctly (the value of foundValue is null).

I'll research what we changed for the component tag between 2.3.14.3 and 2.3.15.
                
> Using findValue() for value stack to retrieve component parameters always returns not-null
object for any parameter name
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-4194
>                 URL: https://issues.apache.org/jira/browse/WW-4194
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.3.15.1
>            Reporter: Sergey Tychina
>            Assignee: Bruce Phillips
>             Fix For: 2.3.17
>
>
> Calling valueStack.findValue("parameter.ANY_STRING") in a component returns not-null
value even if there were no parameters passed to the component.
> Example:
> {code:title=TestAction.java|borderStyle=solid}
> import com.opensymphony.xwork2.ActionSupport;
> import org.apache.struts2.interceptor.ServletRequestAware;
> import javax.servlet.http.HttpServletRequest;
> /**
>  * @author Sergey Tychina
>  */
> public class TestAction extends ActionSupport implements ServletRequestAware {
>     private HttpServletRequest request;
>     public String execute() {
>         return SUCCESS;
>     }
>     @Override
>     public void setServletRequest(HttpServletRequest request) {
>         this.request = request;
>     }
> }
> {code}
> {code:title=testaction.jsp (mapped for success result for the TestAction)|borderStyle=solid}
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <s:component template="/testcomponent.jsp">
>     <s:param name="testval" value="1"/>
> </s:component>
> {code}
> {code:title=testcomponent.jsp|borderStyle=solid}
> <%@ page import="com.opensymphony.xwork2.util.ValueStack" %>
> <%@ page import="org.apache.struts2.ServletActionContext" %>
> <%
>     ValueStack valueStack = (ValueStack) request.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY);
>     Object foundValue = valueStack.findValue("parameters.ANY_PARAM_NAME");
> %>
> <%=foundValue == null ? "NULL" : "NOT NULL"%>
> {code}
> This component will always print "NOT NULL" to the screen.
> Thanks,
>   Sergey.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message