Re: Component-specific javascript in Ajax-Calls

2012-06-04 Thread Thomas Götz
What about this? public class MyComponent extends Panel { public MyComponent(String id) { super(id); setOutputMarkupId(true); } @Override public void renderHead(IHeaderResponse response) { response.renderOnDomReadyJavaScript( $('# +

Re: Component-specific javascript in Ajax-Calls

2012-06-04 Thread Jürgen Lind
Thomas, thanks for this hint, didn't know about that... So the script is executed every time the component is updated in an ajax call, correct? If so, it would surely solve some of my issues. For longer scripts, I would still prefer to have them in the markup file (might be different if we

Re: Component-specific javascript in Ajax-Calls

2012-06-04 Thread Martin Grigorov
On Mon, Jun 4, 2012 at 10:01 PM, Jürgen Lind juergen.l...@iteratec.de wrote: Thomas, thanks for this hint, didn't know about that... So the script is executed every time the component is updated in an ajax call, correct? If so, it would surely solve For every rerender of the component. That

Re: Component-specific javascript in Ajax-Calls

2012-06-04 Thread Jürgen Lind
Thanks Martin, maybe I should have asked before trying to invent my own stuff... Anyway, developing a new wicket tag was some kind of fun as well... J. On 04.06.2012 21:10, Martin Grigorov wrote: On Mon, Jun 4, 2012 at 10:01 PM, Jürgen Lindjuergen.l...@iteratec.de wrote: Thomas, thanks

Re: Component-specific javascript in Ajax-Calls

2012-06-04 Thread Thomas Götz
… or you could put your Javascript code into a template, e.g. like that: MyComponent.js.tmpl: $('#${markupId} .ttr').tipTip({defaultPosition: 'right'}); // ... some long Javascript block …. and in MyComponent.java you'd have: --- public

Re: Component-specific javascript in Ajax-Calls

2012-06-04 Thread Martin Grigorov
On Mon, Jun 4, 2012 at 10:22 PM, Jürgen Lind juergen.l...@iteratec.de wrote: Thanks Martin, maybe I should have asked before trying to invent my own stuff... Anyway, developing a new wicket tag was some kind of fun as well... I'm glad you have fun but I highly recommend staying away from

Re: Component-specific javascript in Ajax-Calls

2012-06-04 Thread Jürgen Lind
Martin, ok, I will think about going to one of the ideas Thomas suggested. I still like the idea that I have my javascript only in the markup file and nothing in the Java class, though... Thanks again, J. On 04.06.2012 21:25, Martin Grigorov wrote: On Mon, Jun 4, 2012 at 10:22 PM, Jürgen

Re: Component specific JavaScript

2012-02-19 Thread Jorge Rodrigez
Hi, I think you just need: class MyComponent extends SomeWicketComponent { @Override public void renderHead(IHeaderResponse response) { response.renderOnDomReadyJavascript(someJSToExecute()); } } someJSToExecute() will be executed every time an instance of MyComponent is rendered. Both

Re: Component specific JavaScript

2012-02-19 Thread Jürgen Lind
Hi Jorge, thanks for the hint, unfortunately, this method is only available in Wicket 1.5 - in this projekt, I am still using Wicket 1.4. Maybe I should stop looking for a general solution for this project and in the future use the solution you suggested... J. On 19.02.2012 10:30, Jorge

Re: Component specific JavaScript

2012-02-19 Thread Martin Grigorov
@wicket.apache.org Sent: Sunday, 19 February 2012, 12:08 Subject: Re: Component specific JavaScript Hi Jorge, thanks for the hint, unfortunately, this method is only available in Wicket 1.5 - in this projekt, I am still using Wicket 1.4. Maybe I should stop looking for a general solution

Re: Component specific JavaScript

2012-02-19 Thread Jürgen Lind
Subject: Re: Component specific JavaScript Hi Jorge, thanks for the hint, unfortunately, this method is only available in Wicket 1.5 - in this projekt, I am still using Wicket 1.4. Maybe I should stop looking for a general solution for this project and in the future use the solution you

Re: Component specific JavaScript

2012-02-19 Thread Martin Grigorov
...@yahoo.com Sent: Sunday, 19 February 2012, 12:37 Subject: Re: Component specific JavaScript Strange, I am using 1.4.12 and neither is present there. The javadoc at http://wicket.apache.org/apidocs/1.4/org/apache/wicket/Component.html also does not show the method with this signature... J

Re: Component specific JavaScript

2012-02-19 Thread Christoph Leiter
On 18.02.2012 17:46, Jürgen Lind wrote: thank you for your reply, I did not know that such a method exists (does it for 1.4 or is this already Wicket 1.5). An secondly: are these handlers fired on a ajax update of an existing DOM Element or only when it is added? This is also available in 1.4.

Re: Component specific JavaScript

2012-02-19 Thread Jürgen Lind
Christoph, I have use yout approach (jQuery + css-class) for some time now as well. However, I have found that if the DOM tree grows rather large, a full scan puts significant load on the browser. That's why I want to be more specific and limit the scanning + updating to the relevant parts of

Re: Component specific JavaScript

2012-02-19 Thread Christoph Leiter
Hi Juergen, there's actually no need to scan the full DOM with this method. :) The first argument of the event handler is the added element. You can simply use it as is or pass it to $() to do jQuery magic just for the relevant part. Christoph On 19.02.2012 13:18, Jürgen Lind wrote:

Re: Component specific JavaScript

2012-02-19 Thread Jürgen Lind
I'm not sure if I get you right on this one: the first argument of which event handler is the added element? Could you probably add some code to illustrate this? J. On 19.02.2012 13:28, Christoph Leiter wrote: Hi Juergen, there's actually no need to scan the full DOM with this method. :) The

Re: Component specific JavaScript

2012-02-19 Thread Christoph Leiter
Sure: $(document).ready(function() { Wicket.Event.subscribe('/dom/node/added', function(element) { $(element).css('border', '1px solid red'); }); }); On 19.02.2012 13:39, Jürgen Lind wrote: I'm not sure if I get you right on this one: the first argument of which event handler

Re: Component specific JavaScript

2012-02-19 Thread Jürgen Lind
Thanks a lot. One last stupid question: is this supposed to work for Wicket 1.4? J. On 19.02.2012 15:28, Christoph Leiter wrote: $(document).ready(function() { Wicket.Event.subscribe('/dom/node/added', function(element) { $(element).css('border', '1px solid red'); }); });

RE: Component specific JavaScript

2012-02-19 Thread Wilhelmsen Tor Iver
Thanks a lot. One last stupid question: is this supposed to work for Wicket 1.4? Doubful, the event system was added in 1.5 - Tor Iver - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands,

Re: Component specific JavaScript

2012-02-19 Thread Jürgen Lind
That's right, I just checked the sources... Anyways, although migration the project now does not make sense, it is a good idea for the next project... Thanks everybody, J. On 20.02.2012 08:31, Wilhelmsen Tor Iver wrote: Thanks a lot. One last stupid question: is this supposed to work for

Re: Component specific JavaScript

2012-02-18 Thread Christoph Leiter
Hello Juergen, you can register a function that gets called when wicket creates a new element in the DOM: Wicket.Event.subscribe('/dom/node/added', function(element) { // do stuff }); You can also use the '/dom/node/removing' channel. Hope this helps. Christoph Jürgen Lind

Re: Component specific JavaScript

2012-02-18 Thread Jürgen Lind
Hi Christoph, thank you for your reply, I did not know that such a method exists (does it for 1.4 or is this already Wicket 1.5). An secondly: are these handlers fired on a ajax update of an existing DOM Element or only when it is added? And where would I put the Javascript that registers the