You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Ganesh Jung (JIRA)" <de...@myfaces.apache.org> on 2010/03/02 09:25:27 UTC

[jira] Created: (MYFACES-2583) f:ajax cannot retrieve clientId from component

f:ajax cannot retrieve clientId from component
----------------------------------------------

                 Key: MYFACES-2583
                 URL: https://issues.apache.org/jira/browse/MYFACES-2583
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-314
    Affects Versions: 2.0.0-beta-2
         Environment: JSF
            Reporter: Ganesh Jung


This code:
		<h:form id="myForm">
	    	<h:inputText value="#{myBean.test}">
				<f:ajax render="#{myBean.bindingMyTest.clientId}" event="keyup"/> 
	    	</h:inputText>
	    	<h:inputText id="myText" value="#{myBean.test}" binding="#{myBean.bindingMyTest}" />
		</h:form>

produces java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection

while this works:
		<h:form id="myForm">
	    	<h:inputText value="#{myBean.test}">
				<f:ajax render="myForm:myText" event="keyup"/> 
	    	</h:inputText>
	    	<h:inputText id="myText" value="#{myBean.test}"/>
		</h:form>

On Mojarra both work fine. My guess is here's some problem with the special lifecycle of bindings properties.

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


[jira] Commented: (MYFACES-2583) f:ajax cannot retrieve clientId from component

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

Jakob Korherr commented on MYFACES-2583:
----------------------------------------

After digging into this problem I realized that this seems to be a different problem. The problem is that the ValueExpression (in our case for the attribute render, but in the code also for execute) is evaluated when the component tree is built, which is completely wrong, because this prohibits the real usage of ValueExpressions: changing values!

In your case, Ganesh, the real problem is that at the time the ValueExpression is evaluated, the component is not yet bound to the property in the managed bean and thus the ValueExpression resolves to null and thus the String is not "parsed" into a Collection at that time. Then, when the render attribute is evaluated, the ValueExpression resolves to the clientId, which is of course a String, but the runtime expects a (pre-processed) Collection. Thus the ClassCastException.

> f:ajax cannot retrieve clientId from component
> ----------------------------------------------
>
>                 Key: MYFACES-2583
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2583
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>         Environment: JSF
>            Reporter: Ganesh Jung
>         Attachments: MyFaces_Test.war
>
>
> This code:
> 		<h:form id="myForm">
> 	    	<h:inputText value="#{myBean.test}">
> 				<f:ajax render="#{myBean.bindingMyTest.clientId}" event="keyup"/> 
> 	    	</h:inputText>
> 	    	<h:inputText id="myText" value="#{myBean.test}" binding="#{myBean.bindingMyTest}" />
> 		</h:form>
> produces java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection
> while this works:
> 		<h:form id="myForm">
> 	    	<h:inputText value="#{myBean.test}">
> 				<f:ajax render="myForm:myText" event="keyup"/> 
> 	    	</h:inputText>
> 	    	<h:inputText id="myText" value="#{myBean.test}"/>
> 		</h:form>
> On Mojarra both work fine. My guess is here's some problem with the special lifecycle of bindings properties.

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


[jira] Commented: (MYFACES-2583) f:ajax cannot retrieve clientId from component

Posted by "Ganesh Jung (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840535#action_12840535 ] 

Ganesh Jung commented on MYFACES-2583:
--------------------------------------

This is what I call fast! Thank you, Jakob!

> f:ajax cannot retrieve clientId from component
> ----------------------------------------------
>
>                 Key: MYFACES-2583
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2583
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>         Environment: JSF
>            Reporter: Ganesh Jung
>            Assignee: Jakob Korherr
>             Fix For: 2.0.0-beta-3
>
>         Attachments: MyFaces_Test.war
>
>
> This code:
> 		<h:form id="myForm">
> 	    	<h:inputText value="#{myBean.test}">
> 				<f:ajax render="#{myBean.bindingMyTest.clientId}" event="keyup"/> 
> 	    	</h:inputText>
> 	    	<h:inputText id="myText" value="#{myBean.test}" binding="#{myBean.bindingMyTest}" />
> 		</h:form>
> produces java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection
> while this works:
> 		<h:form id="myForm">
> 	    	<h:inputText value="#{myBean.test}">
> 				<f:ajax render="myForm:myText" event="keyup"/> 
> 	    	</h:inputText>
> 	    	<h:inputText id="myText" value="#{myBean.test}"/>
> 		</h:form>
> On Mojarra both work fine. My guess is here's some problem with the special lifecycle of bindings properties.

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


[jira] Resolved: (MYFACES-2583) f:ajax cannot retrieve clientId from component

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2583?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jakob Korherr resolved MYFACES-2583.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0-beta-3
         Assignee: Jakob Korherr

> f:ajax cannot retrieve clientId from component
> ----------------------------------------------
>
>                 Key: MYFACES-2583
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2583
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>         Environment: JSF
>            Reporter: Ganesh Jung
>            Assignee: Jakob Korherr
>             Fix For: 2.0.0-beta-3
>
>         Attachments: MyFaces_Test.war
>
>
> This code:
> 		<h:form id="myForm">
> 	    	<h:inputText value="#{myBean.test}">
> 				<f:ajax render="#{myBean.bindingMyTest.clientId}" event="keyup"/> 
> 	    	</h:inputText>
> 	    	<h:inputText id="myText" value="#{myBean.test}" binding="#{myBean.bindingMyTest}" />
> 		</h:form>
> produces java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection
> while this works:
> 		<h:form id="myForm">
> 	    	<h:inputText value="#{myBean.test}">
> 				<f:ajax render="myForm:myText" event="keyup"/> 
> 	    	</h:inputText>
> 	    	<h:inputText id="myText" value="#{myBean.test}"/>
> 		</h:form>
> On Mojarra both work fine. My guess is here's some problem with the special lifecycle of bindings properties.

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


[jira] Commented: (MYFACES-2583) f:ajax cannot retrieve clientId from component

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

Jakob Korherr commented on MYFACES-2583:
----------------------------------------

I guess the problem is that it was thought that a ValueExpression for the render property of f:ajax has to resolve to a Collection of clientIds. But, of course, it can also resolve to a String.

So the only thing to do here is check the type of the resolved ValueExpression also for String and handle it separately. I'll do this today, if that's ok for you, Ganesh.

> f:ajax cannot retrieve clientId from component
> ----------------------------------------------
>
>                 Key: MYFACES-2583
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2583
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>         Environment: JSF
>            Reporter: Ganesh Jung
>         Attachments: MyFaces_Test.war
>
>
> This code:
> 		<h:form id="myForm">
> 	    	<h:inputText value="#{myBean.test}">
> 				<f:ajax render="#{myBean.bindingMyTest.clientId}" event="keyup"/> 
> 	    	</h:inputText>
> 	    	<h:inputText id="myText" value="#{myBean.test}" binding="#{myBean.bindingMyTest}" />
> 		</h:form>
> produces java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection
> while this works:
> 		<h:form id="myForm">
> 	    	<h:inputText value="#{myBean.test}">
> 				<f:ajax render="myForm:myText" event="keyup"/> 
> 	    	</h:inputText>
> 	    	<h:inputText id="myText" value="#{myBean.test}"/>
> 		</h:form>
> On Mojarra both work fine. My guess is here's some problem with the special lifecycle of bindings properties.

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