Mark Collette wrote:
> Mark Collette wrote:
>
>> In the method
>> javax.faces.component.MessageFactory.getLabel(FacesContext,UIComponent),
>> at the line where o = component.getValueExpression("label"), should
>> getLabel(-) be returning the evaluation of the ValueExpression, and
>> not the ValueExpression itself?
>>
>>
>> |*
>> <http://java.sun.com/javaee/5/docs/api/javax/el/ValueExpression.html#getValue%28javax.el.ELContext%29>*|
>> static Object getLabel(FacesContext context,
>> UIComponent component) {
>> Object o =
>> component.getAttributes().get("label");
>> if (o == null || (o instanceof String && ((String) o).length() ==
>> 0)) {
>> o = component.getValueExpression("label");
>> <<<<<<<<<<<<<<<<
>> }
>> // Use the "clientId" if there was no label specified.
>> if (o == null) {
>> o = component.getClientId(context);
>> }
>> return o;
>> }
>>
>>
>> - Mark Collette
>>
>>
> Also, if the attribute "label"'s value had been null, then it would
> have used the ValueExpression, and since ValueExpression's of type
> String can not evaluate to null, but instead an empty String, then
> will the last if(o == null) ever evaluate to true? Should it not
> replicate the String of length 0 test as well, and be inside of the
> first if statement?
Most likely, yes.
String label = (String) component.getAttributes().get("label");
if (label == null || label.length() == 0) {
label = component.getClientId(context);
}
return label;
(I think it makes sense to introduce a signature change as well)
I think the above would be sufficient.
>
> - Mark Collette
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>