dev@javaserverfaces.java.net

Re: javax.faces.component.MessageFactory.getLabel(FacesContext,UIComponent)

From: Mark Collette <mark.collette_at_icesoft.com>
Date: Mon, 29 Oct 2007 13:43:11 -0600

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?

- Mark Collette