[ 
https://issues.apache.org/jira/browse/MYFACES-2755?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12879335#action_12879335
 ] 

Werner Punz commented on MYFACES-2755:
--------------------------------------

Ok this is not entirely javascript related at least not in my part of the code 
is the problem here is following:

onclick = "jsf.ajax.request(this, event, { execute: this.id, render: 'counter' 
}); return false;"
is mapped into

var cf = function(){jsf.ajax.request(this, event, { execute: this.id, render: 
'counter' }); return false;};var oamSF = function(){};return (cf()==false)? 
false : oamSF();

which reassigns the this scope (whoever has written that code did not take that 
into consideration.
the problem then is that this is assigned to the function cf which then tries 
to determine the original this.id id value.

But now that this points towards the function id is undefined.

A quick workaround to fix that problem would be to use one of our impl functions

the call would look like: cf myfaces._impl._util._Lang.hitch(this, 
(){jsf.ajax.request(this, event, { execute: this.id, render: 'counter' }); 
return false;});

this would reassign the this to the original scope. 
if you do not want to go for the helper in our impls Lang package then a 
workaround would be to 
go for following code:

var cf = function(){jsf.ajax.request(this, event, { execute: this.id, render: 
'counter' }); return false;};var oamSF = function(){};return (cf.apply(this, 
[])==false)? false : oamSF.apply(this, []);

This would drag the scope also in.

Cheers Werner

Leonardo or Jakob can you take over you probably know fastest where the related 
code is.









> this.id is undefined in jsf.ajax.request (regression from 2.0.0)
> ----------------------------------------------------------------
>
>                 Key: MYFACES-2755
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2755
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.1
>            Reporter: Michael Concini
>
> With the new javascript, we now wrapper calls into jsf.ajax.request with a 
> function call.  So for example this:
> <h:commandButton id="incrementButton" value="Increment"
>                        onclick="jsf.ajax.request(this, event, { execute: 
> this.id, render: 'counter' }); return false;"
>                        actionListener="#{counter.increment}" />
> would be rendered as this:
> <input id="incrementButton" name="incrementButton" type="submit" 
> value="Increment"
> onclick="var cf = function(){jsf.ajax.request(this, event, { execute: 
> this.id, render: 'counter' }); return false;};var oamSF = function(){};return 
> (cf()==false)? false : oamSF();" />
> The problem is that we've broken the reference to this.id as it is undefined 
> at the function's scope. This works fine in both the 2.0.0 release as well as 
> Mojarra.

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

Reply via email to