Export to GitHub

primefaces - issue #2672

Bug in DataHelper resolveField method


Posted on Oct 20, 2011 by Happy Camel

We use p:datatable within our own composite component. Also the p:columns are wrapped in our own component. It is not possible to set the "sortBy" attribute of p:column with a value expression. Internally the DataHelper class just removes #{} and the table variable from the expression string. The expression itself is not evaluated.

Here´s a possible solution for that problem that works perfect for us:

String resolveField(ValueExpression expression) { Object newValue = expression.getValue(FacesContext.getCurrentInstance().getELContext());

if (newValue == null || !(newValue instanceof String))
    return resolveField_old (expression);
else {
    String val = (String)newValue;
    return val.substring(val.indexOf(".") + 1);
}

}

String resolveField_old(ValueExpression expression) { String expressionString = expression.getExpressionString(); expressionString = expressionString.substring(2, expressionString.length() - 1); //Remove #{}

return expressionString.substring(expressionString.indexOf(".") + 1);                //Remove var
}

This feature is really important for us.

What steps will reproduce the problem? 1. sortBy="#{item.firstname}" works because the logic extracts "firstname" 2. sortBy="#{column.sortByExpression}" doesn´t work because the expression is not evaluated

What is the PrimeFaces version? 2.2.1

What is the expected output? What do you see instead? I expect that the sortBy expression is evaluated

Which JSF implementation with version are you using?(Mojarra or MyFaces) Mojarra

Which component libraries are you using in addition to PrimeFaces? None

Which application server or servlet container are you using? Glassfish 3.1

Comment #1

Posted on Oct 27, 2011 by Happy Camel

This bug describes a similar problem with the DataHelper class.

http://code.google.com/p/primefaces/issues/detail?id=2349

Multiple selection doesn´t work because of wrong (missing) expression evaluation.

Comment #2

Posted on Dec 3, 2011 by Swift Rhino

Issue 2349 has been merged into this issue.

Comment #3

Posted on Dec 3, 2011 by Swift Rhino

Review for RC1.

Comment #4

Posted on Dec 4, 2011 by Swift Rhino

(No comment was entered for this change.)

Comment #5

Posted on Jul 10, 2012 by Helpful Dog

Comment deleted

Status: Fixed

Labels:
Priority-Medium Type-Defect TargetVersion-3.0 TargetVersion-3.0.RC1