Re: RenderSupport Scope

2010-05-30 Thread Martin Strand

If you want to declare a global function from within Tapestry.onDOMLoaded, you 
can simply add it to the windows object:

window.myGlobalFunction = function() {
  doCoolStuff();
}

You can then access that function from anywhere if you prefer to do things this 
way:

img onclick=window.myGlobalfunction() src=... /


Martin

On Sun, 30 May 2010 04:59:44 +0200, Pablo dos Reis pablodosr...@gmail.com 
wrote:


Hi Thiago,

When the Tapestry creates the script.
It puts the script inside a other method.
Tapestry.onDOMLoaded() in this case.

So when I try call it method using a js the method created by RenderSupport
is not visible for js.



I resolved the following
  writer.element(script, language, JavaScript);
writer.write(script);
writer.end();

Then ran!!

But maybe is not the better way.

I had to use RenderSupport because in js I don't know the element's id for
implements a method that return the component value.

2010/5/29 Thiago H. de Paula Figueiredo thiag...@gmail.com


On Sat, 29 May 2010 23:18:28 -0300, Pablo dos Reis pablodosr...@gmail.com
wrote:

 When I inject javaScript using renderSupport not is possible access the

methods created in the class through a js file.



Hi, Pablo!

I'm not sure what you're talking about, but remember that any JavaScript
code added through RenderSupport.addScript() ends up in a script tag in
the end of the body. Avoid overriding methods in this case: just generate
the minimum amount of code needed and let the heavy lifting for .js files.
;)

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: RenderSupport Scope

2010-05-29 Thread Thiago H. de Paula Figueiredo
On Sat, 29 May 2010 23:18:28 -0300, Pablo dos Reis  
pablodosr...@gmail.com wrote:



When I inject javaScript using renderSupport not is possible access the
methods created in the class through a js file.


Hi, Pablo!

I'm not sure what you're talking about, but remember that any JavaScript  
code added through RenderSupport.addScript() ends up in a script tag in  
the end of the body. Avoid overriding methods in this case: just  
generate the minimum amount of code needed and let the heavy lifting for  
.js files. ;)


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: RenderSupport Scope

2010-05-29 Thread Pablo dos Reis
Hi Thiago,

When the Tapestry creates the script.
It puts the script inside a other method.
Tapestry.onDOMLoaded() in this case.

So when I try call it method using a js the method created by RenderSupport
is not visible for js.



I resolved the following
  writer.element(script, language, JavaScript);
writer.write(script);
writer.end();

Then ran!!

But maybe is not the better way.

I had to use RenderSupport because in js I don't know the element's id for
implements a method that return the component value.

2010/5/29 Thiago H. de Paula Figueiredo thiag...@gmail.com

 On Sat, 29 May 2010 23:18:28 -0300, Pablo dos Reis pablodosr...@gmail.com
 wrote:

  When I inject javaScript using renderSupport not is possible access the
 methods created in the class through a js file.


 Hi, Pablo!

 I'm not sure what you're talking about, but remember that any JavaScript
 code added through RenderSupport.addScript() ends up in a script tag in
 the end of the body. Avoid overriding methods in this case: just generate
 the minimum amount of code needed and let the heavy lifting for .js files.
 ;)

 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




-- 
Pablo Henrique dos Reis