Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3520

False evaluation of variables/params with the same name (c:forEach "var" and "varStatus" should be page scoped)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.6
    • 2.0.15, 2.1.9
    • None
    • None

    Description

      I have an scenario where an xhml is included. The included file has a parameter with the same name as some outer variable. In the included file the parameter is ignored and the outer variable is used.

      Some xhtml:
      <c:forEach var="item" begin="1" end="3">
      <div>
      <ui:include src="templateContextTestInclude.xhtml">
      <ui:param name="item" value="#

      {item + 10}

      " />
      </ui:include>
      </div>
      </c:forEach>

      templateContextTestInclude.xhtml:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:t="http://myfaces.apache.org/tomahawk">

      <body>
      <ui:composition>
      Item: <h:outputText value="#

      {item}

      " /><br/>
      </ui:composition>
      </body>
      </html>

      I found out that the "hierarchy" of VariableMappers is asked for a value before the 'DefaultVariableMapper' tests the current template/page context. That was not what I expected. Is that how it should be?
      In JSF1 it works that way.

      (If I change the VariableMapperWrapper locally to test the template/page context first the behaviour is as I would have expected (don't know if it is the right place ):
      public ValueExpression resolveVariable(String variable)
      {

      AbstractFaceletContext faceletContext = (AbstractFaceletContext) FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);

      //Check on page and template context
      PageContext pageContext = faceletContext.getPageContext();
      if (pageContext != null && pageContext.getAttributeCount() > 0)
      {
      if (pageContext.getAttributes().containsKey(variable))
      {
      ValueExpression returnValue = pageContext.getAttributes().get(variable);
      if (_trackResolveVariables)

      { _variableResolved = true; }
      return returnValue;
      }
      }

      TemplateContext templateContext = faceletContext.getTemplateContext();
      if (templateContext != null && !templateContext.isParameterEmpty())
      {
      if (templateContext.getParameterMap().containsKey(variable))
      {
      ValueExpression returnValue = templateContext.getParameter(variable);
      if (_trackResolveVariables)
      { _variableResolved = true; }

      return returnValue;
      }
      }

      ValueExpression ve = null;
      ....
      )

      Thanks in advance,
      dennis

      Attachments

        1. MYFACES-3520-1.patch
          23 kB
          Leonardo Uribe

        Activity

          People

            lu4242 Leonardo Uribe
            hoersch dennis hoersch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: