myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: Question about createValueBinding
Date Tue, 10 Apr 2007 01:07:33 GMT
fastbob wrote:
> I have a question about createValueBinding (I realize it's deprecated in JSF
> 1.2). Should the following code sequence throw an exception?
>         FacesContext context = getContext();
>         ValueBinding binding = context.getApplication().createValueBinding(
> "This is a string");
> This throws the following exception in MyFaces 1.1.3:
> 17:19:16,453 INFO  [STDOUT] javax.faces.el.ReferenceSyntaxException: Invalid
> expression: 'This is a string'. Parsed Expression of unexpected type
> java.lang.String

It's an odd message. However the code should be:

Only strings starting with "#{" are acceptable as parameters to this 
method, and the expression must reference a java object, eg 
"". A value-binding is a subset of EL-expressions and 
cannot take just a random string.

Internally, it looks like the org.apache.commons.el.parser.ELParser 
class returns the original value for its "expressionString" if it cannot 
parse the input, and some subclass of Expression or ExpressionString 
otherwise. The code then checks for the expected 
Expression/ExpressionString type and fails (throws the exception). The 
check could be improved here so that a better error message (eg 
"Unparsable expression") is reported but the basic behaviour seems 
correct to me.



View raw message