You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org> on 2010/02/12 15:34:28 UTC

[jira] Created: (MYFACES-2552) TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute

TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute
-----------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: MYFACES-2552
                 URL: https://issues.apache.org/jira/browse/MYFACES-2552
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-314
    Affects Versions: 2.0.0-beta-2
            Reporter: Jakob Korherr
            Assignee: Jakob Korherr


if you have a facelets composite component with an attribute "test" that points to a property in a managed bean (e.g. #{myBean.property}) which is currently null and you refer to that attribute in the implementation via #{cc.attrs.test} you can get the current value (null) or set a new value but you cannot get the type of the property (e.g. String[]). However if the property in the managed bean is non-null you can get the type.

For example:

<cc:interface name="mycomponent">
    <cc:attribute name="test" required="true"/>
</cc:interface>
<cc:implementation>
    <h:selectManyListbox value="#{cc.attrs.test}">
        <f:selectItems value="#{some select items}"/>
    </h:selectManyListbox>
</cc:implementation>

--> calling #{cc.attrs.test}.getType() will fail if #{cc.attrs.test} resolves to null, but will work if #{cc.attrs.test} resolves to some valid value.

This currently results in a NullPointerException in _SharedRendererUtils.getConvertedUISelectManyValue().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2552) TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12833040#action_12833040 ] 

Jakob Korherr commented on MYFACES-2552:
----------------------------------------

One solution for this would be to return a special type != Map when resolving #{cc.attrs} and providing a special ELResolver for this type. Then we could use the original ValueExpressions of the attributes from the composite component to determine the type. Of course this would totally break the spec!!!

What are your opinions about that? Is this too unimportant to make such great changes or should we consult the EG and maybe change this behavior? Maybe in the next major release (2.1)?

> TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute
> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-2552
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2552
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>            Reporter: Jakob Korherr
>            Assignee: Jakob Korherr
>
> if you have a facelets composite component with an attribute "test" that points to a property in a managed bean (e.g. #{myBean.property}) which is currently null and you refer to that attribute in the implementation via #{cc.attrs.test} you can get the current value (null) or set a new value but you cannot get the type of the property (e.g. String[]). However if the property in the managed bean is non-null you can get the type.
> For example:
> <cc:interface name="mycomponent">
>     <cc:attribute name="test" required="true"/>
> </cc:interface>
> <cc:implementation>
>     <h:selectManyListbox value="#{cc.attrs.test}">
>         <f:selectItems value="#{some select items}"/>
>     </h:selectManyListbox>
> </cc:implementation>
> --> calling #{cc.attrs.test}.getType() will fail if #{cc.attrs.test} resolves to null, but will work if #{cc.attrs.test} resolves to some valid value.
> This currently results in a NullPointerException in _SharedRendererUtils.getConvertedUISelectManyValue().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2552) TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12833029#action_12833029 ] 

Jakob Korherr commented on MYFACES-2552:
----------------------------------------

I just found out why this happens: #{cc.attrs} resolves to a Map (CompositeComponentAttributesMapWrapper) and thus javax.el.MapELResolver is used to resolve the values. Here is the important part of the implementation of the getType() method from Tomcat:

if (base instanceof Map<?,?>) {
    context.setPropertyResolved(true);
    Object obj = ((Map<?,?>) base).get(property);
    return (obj != null) ? obj.getClass() : null;
}

This explains the behavior. So we can only circumvent this by not using a Map, however I don't know if we should really change this...

> TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute
> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-2552
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2552
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>            Reporter: Jakob Korherr
>            Assignee: Jakob Korherr
>
> if you have a facelets composite component with an attribute "test" that points to a property in a managed bean (e.g. #{myBean.property}) which is currently null and you refer to that attribute in the implementation via #{cc.attrs.test} you can get the current value (null) or set a new value but you cannot get the type of the property (e.g. String[]). However if the property in the managed bean is non-null you can get the type.
> For example:
> <cc:interface name="mycomponent">
>     <cc:attribute name="test" required="true"/>
> </cc:interface>
> <cc:implementation>
>     <h:selectManyListbox value="#{cc.attrs.test}">
>         <f:selectItems value="#{some select items}"/>
>     </h:selectManyListbox>
> </cc:implementation>
> --> calling #{cc.attrs.test}.getType() will fail if #{cc.attrs.test} resolves to null, but will work if #{cc.attrs.test} resolves to some valid value.
> This currently results in a NullPointerException in _SharedRendererUtils.getConvertedUISelectManyValue().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2552) TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12833046#action_12833046 ] 

Jakob Korherr commented on MYFACES-2552:
----------------------------------------

For now I'll commit a very ugly temporal workaround for this. Note that mojarra currently does the same thing as this workaround for this special scenario.

> TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute
> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-2552
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2552
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>            Reporter: Jakob Korherr
>            Assignee: Jakob Korherr
>
> if you have a facelets composite component with an attribute "test" that points to a property in a managed bean (e.g. #{myBean.property}) which is currently null and you refer to that attribute in the implementation via #{cc.attrs.test} you can get the current value (null) or set a new value but you cannot get the type of the property (e.g. String[]). However if the property in the managed bean is non-null you can get the type.
> For example:
> <cc:interface name="mycomponent">
>     <cc:attribute name="test" required="true"/>
> </cc:interface>
> <cc:implementation>
>     <h:selectManyListbox value="#{cc.attrs.test}">
>         <f:selectItems value="#{some select items}"/>
>     </h:selectManyListbox>
> </cc:implementation>
> --> calling #{cc.attrs.test}.getType() will fail if #{cc.attrs.test} resolves to null, but will work if #{cc.attrs.test} resolves to some valid value.
> This currently results in a NullPointerException in _SharedRendererUtils.getConvertedUISelectManyValue().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2552) TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12833297#action_12833297 ] 

Leonardo Uribe commented on MYFACES-2552:
-----------------------------------------

I think the only thing we can do is assume this case return null and deal with it, retrieving the real value and check its type. It is possible to change the ELResolver (Flash object implements Map but FlashELResolver resolve its values, instead MapELResolver).

In this example there is no way to check the type without retrieve the value, and note #{cc.attrs} is a Map<String,Object>. I remember variants of the same issue long time ago on myfaces and in that time the solution was the same.

> TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute
> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-2552
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2552
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>            Reporter: Jakob Korherr
>            Assignee: Jakob Korherr
>
> if you have a facelets composite component with an attribute "test" that points to a property in a managed bean (e.g. #{myBean.property}) which is currently null and you refer to that attribute in the implementation via #{cc.attrs.test} you can get the current value (null) or set a new value but you cannot get the type of the property (e.g. String[]). However if the property in the managed bean is non-null you can get the type.
> For example:
> <cc:interface name="mycomponent">
>     <cc:attribute name="test" required="true"/>
> </cc:interface>
> <cc:implementation>
>     <h:selectManyListbox value="#{cc.attrs.test}">
>         <f:selectItems value="#{some select items}"/>
>     </h:selectManyListbox>
> </cc:implementation>
> --> calling #{cc.attrs.test}.getType() will fail if #{cc.attrs.test} resolves to null, but will work if #{cc.attrs.test} resolves to some valid value.
> This currently results in a NullPointerException in _SharedRendererUtils.getConvertedUISelectManyValue().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2552) TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12833809#action_12833809 ] 

Jakob Korherr commented on MYFACES-2552:
----------------------------------------

Filed spec issue: https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=745

> TagValueExpression.getType() returns null if the property in the managed bean is null and the expression points to a facelets composite component attribute
> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-2552
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2552
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>            Reporter: Jakob Korherr
>            Assignee: Jakob Korherr
>         Attachments: MYFACES-2552-spec-proposal.patch
>
>
> if you have a facelets composite component with an attribute "test" that points to a property in a managed bean (e.g. #{myBean.property}) which is currently null and you refer to that attribute in the implementation via #{cc.attrs.test} you can get the current value (null) or set a new value but you cannot get the type of the property (e.g. String[]). However if the property in the managed bean is non-null you can get the type.
> For example:
> <cc:interface name="mycomponent">
>     <cc:attribute name="test" required="true"/>
> </cc:interface>
> <cc:implementation>
>     <h:selectManyListbox value="#{cc.attrs.test}">
>         <f:selectItems value="#{some select items}"/>
>     </h:selectManyListbox>
> </cc:implementation>
> --> calling #{cc.attrs.test}.getType() will fail if #{cc.attrs.test} resolves to null, but will work if #{cc.attrs.test} resolves to some valid value.
> This currently results in a NullPointerException in _SharedRendererUtils.getConvertedUISelectManyValue().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.