dev@javaserverfaces.java.net

Re: EL: isReadOnly()

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Fri, 21 Dec 2007 09:45:06 -0800

Matthias Wessendorf wrote:
> ok,
> forget the posted JSPX.
>
> Inside of Trinidad's EditableValueRenderer
> (org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.EditableValueRenderer)
>
> there getReadOnly(...), which is called by all inputXyz Renderers to
> check if the component should be rendered "readOnly" or not
> That method checks if the component is readOnly and it also checks if
> the underlying EL is readOnly.
>
> If that method returns TRUE, the component is readOnly (and there for
> a inputText isn't editable).
> makes sense, so far.
>
> Here is a "use-case"
>
> <tr:inputText label="Label a)" value=""/>
> (yes, may be stupid, but can happen...)
>
> Since the getReadOnly() checks if the EL is readOnly... it does this as well:
>
> ValueExpression ve = getValueExpression(bean);
>
> In Jetty (jetty-6.1.2rc2), which uses Sun/Glassfish/RI EL
> (com.sun.el.ValueExpressionImpl)
> ==>
> It returns an object that is readOnly (which is correct) and the
> getExpressionString is "" (empty).
>
> In tomcat 6. which uses this EL-Impl
> "org.apache.jasper.el.JspValueExpression", it returns NULL
>
>
> Now, I wonder what the correct EL behavior is.
> I tend to think, that Tomcat is right, because there is no
> ExpressionString, so not a "real" Expression,
> but others could have a different understanding of it.
>
If it's not a real expression then shouldn't it be read-only? You
certainly can't call
setValue() on it and expect it to work. So I think my original quote
still holds true.


> What is your take on that ?
>
> -Matthias
>
>
>
> On Dec 20, 2007 11:39 PM, Matthias Wessendorf <matzew_at_apache.org> wrote:
>
>> yah,
>> tomorrow :-)
>>
>>
>> On Dec 20, 2007 9:09 PM, Jacob Hookom <jacob_at_hookom.net> wrote:
>>
>>> I agree with Ryan, it should be read-only-- if you get that VE, can you
>>> do a getClass() on it and let us know the type?
>>>
>>>
>>> Ryan Lubke wrote:
>>>
>>>> Matthias Wessendorf wrote:
>>>>
>>>>> ok, this is only in Jetty;
>>>>> just tested w/ a tomcat 6.x
>>>>>
>>>>> and <tr:inputText label="Label a)" value=""/>
>>>>> renders as a regular inputText field;
>>>>>
>>>>>
>>>> I think this may be a bug in Tomcat. The javadocs for ValueExpression
>>>> states:
>>>>
>>>> <quote>
>>>> In previous incarnations of this API, expressions could only be read.
>>>> ValueExpression objects can now be
>>>> used both to retrieve a value and to set a value. Expressions that can
>>>> have a value set on them are referred to as
>>>> l-value expressions. Those that cannot are referred to as r-value
>>>> expressions. Not all r-value expressions can be
>>>> used as l-value expressions (e.g. "${1+1}" or "${firstName}
>>>> ${lastName}"). See the EL
>>>> Speciļ¬cation for details. Expressions that cannot be used as l-values
>>>> must always return true from
>>>> isReadOnly().
>>>> </quote>
>>>>
>>>>
>>>>
>>>>
>>>>> -M
>>>>>
>>>>> On Dec 20, 2007 5:43 PM, Matthias Wessendorf <matzew_at_apache.org> wrote:
>>>>>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have a <tr:inputText value="">
>>>>>> The underlying API, says this ValueExpression is readOnly.
>>>>>>
>>>>>> A simple JSPX makes that clear
>>>>>> (I am on JETTY jetty-6.1.2rc2 and the RI )
>>>>>> I think, they (re) use the glassfish shipped javax.el
>>>>>>
>>>>>>
>>>>>> <?xml version='1.0' encoding='utf-8'?>
>>>>>> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
>>>>>>
>>>>>> <jsp:directive.page contentType="text/plain"/>
>>>>>> <jsp:directive.page import="javax.servlet.jsp.*"/>
>>>>>> <jsp:directive.page import="javax.el.*"/>
>>>>>> <jsp:directive.page import="javax.faces.context.*"/>
>>>>>> <jsp:scriptlet>
>>>>>> JspApplicationContext jac =
>>>>>> JspFactory.getDefaultFactory().getJspApplicationContext(application);
>>>>>> ExpressionFactory ef = jac.getExpressionFactory();
>>>>>> ValueExpression ve = ef.createValueExpression("", Object.class);
>>>>>> out.println(ve.isLiteralText());
>>>>>>
>>>>>> out.println(ve.isReadOnly(FacesContext.getCurrentInstance().getELContext()));
>>>>>>
>>>>>>
>>>>>> </jsp:scriptlet>
>>>>>> </jsp:root>
>>>>>>
>>>>>> --
>>>>>> Matthias Wessendorf
>>>>>>
>>>>>> further stuff:
>>>>>> blog: http://matthiaswessendorf.wordpress.com/
>>>>>> sessions: http://www.slideshare.net/mwessendorf
>>>>>> mail: matzew-at-apache-dot-org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
>>>> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
>>> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>>>
>>>
>>>
>>
>> --
>> Matthias Wessendorf
>>
>> further stuff:
>> blog: http://matthiaswessendorf.wordpress.com/
>> sessions: http://www.slideshare.net/mwessendorf
>> mail: matzew-at-apache-dot-org
>>
>>
>
>
>
>