myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Korherr <jakob.korh...@gmail.com>
Subject Re: javascript problem with commandlink and onclick after update to JSF 1.2
Date Mon, 04 Jan 2010 15:04:35 GMT
Hi Michael,

Unfortunately I don't think it is possible to refer to the clicked link
inside the function definition. The only way I know is to use
document.getElementById('...').

»How is the id of the commandLink placed into oamSubmitForm as parameter?«
The renderer of the command link generates this javascript and so it puts
the id there.

>From my point of view it would be great if myfaces would replace »this« with
»document.getElementById('clienId')« automatically. However, I don't know if
this violates the jsf 1.2 spec.

Regards,
Jakob

2010/1/4 Michael Heinen <michael.heinen@recommind.com>

> Hi,
>
> I have another problem after my update from myfaces 1.1.5 to 1.2.8.
> I cannot use "this" anymore in onclick attributes of commandLinks due to
> changed rendering of commandLinks. Instead of the link the outer form is
> accessed via "this".
>
> sample:
> <h:form id="tabform" ...>
> <t:commandLink id="tabTemplates" forceId="true"
>               onclick="alert(this.id);"
>               action="#{...}">
>
> output with 1.1.5: tabTemplates
> output with 1.2.8: tabform
>
> rendered html onclick attributes:
> myfaces 1.2.8: onclick=var cf = function(){alert(this.id);var oamSF =
> function(){return oamSubmitForm('tabform','tabTemplates');};return
> (cf()==false)? false : oamSF();
> myfaces 1.1.5: onclick=alert(this.id);
>
> One workaround is something like this:
> onclick="var me1=getObj('tabTemplates'); alert(m1);"
>
> This change is unfortunately really expensive and error-prone for me
> because I used this construct more than hundred times and often it is
> generated dynamically :-(
>
> Is there any other workaround or trick to access the clicked link in the
> onclick attribute via javascript inside a function definition?
> How is the id of the commandLink placed into oamSubmitForm as parameter?
>
> Michael
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message