False evaluation of variables/params with the same name
-------------------------------------------------------
Key: MYFACES-3520
URL: https://issues.apache.org/jira/browse/MYFACES-3520
Project: MyFaces Core
Issue Type: Bug
Affects Versions: 2.1.6
Reporter: dennis hoersch
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
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira