tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 52440] New: Wrong getValueReference behaviour with Facelets parameter expressions
Date Mon, 09 Jan 2012 09:11:20 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=52440

             Bug #: 52440
           Summary: Wrong getValueReference behaviour with Facelets
                    parameter expressions
           Product: Tomcat 7
           Version: 7.0.22
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Servlet & JSP API
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: justas.ratkevicius@gmail.com
    Classification: Unclassified


ValueExpression method getValueReference should return base object and
property. But it returns null if ValueExpression is Facelets parameter.
Example:

someVar = #{concreteObject.property}

ValueExpression for #{someVar} return null from method getValueReference (guess
because it is simple expression #{someVar}), but logicaly it should return
parent expressions ValueReference (need hierachical ValueReference lookup).

I made workaround with Java Reflect API in my code and it illustrates problem:

ELContext elContext = FacesContext.getCurrentInstance().getELContext();
ValueReference reference = exp.getValueReference(elContext);

if (reference == null && exp instanceof TagValueExpressionUEL) {
    ValueExpressionImpl origExp = (ValueExpressionImpl)
((TagValueExpressionUEL) exp).getWrapped();

    // TODO: JR: find better way to get base and property. ! Code is not
portable because uses Tomcat EL implementation details. ! 
    Field field = ReflectionUtils.findField(origExp.getClass(),
EL_IMPL_VAR_PROPERTY);
    field.setAccessible(true);
    VariableMapper varMapper = (VariableMapper) ReflectionUtils.getField(field,
origExp);
    field = ReflectionUtils.findField(origExp.getClass(),
EL_IMPL_NODE_PROPERTY);
    field.setAccessible(true);
    SimpleNode node = (SimpleNode) ReflectionUtils.getField(field, origExp);

    if (varMapper != null && node != null) {
        ValueExpression parentExp = varMapper.resolveVariable(node.getImage());
        if (parentExp != null) {
            try {
                reference = parentExp.getValueReference(elContext);

                if (reference == null) {
                    reference = getValueReference(parentExp);
                }
            } catch (PropertyNotFoundException e) {
                LOG.warn("Property not found: " + e.getMessage());
            }
        }
    }
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message