Re: Execute Javascript after components of a certain type render
Your suggestions worked. Thank you both! On Mon, Jan 23, 2012 at 1:50 PM, Alec Swan alecs...@gmail.com wrote: What about AbstractTransformerBehavior? Can I use it to execute Javascript? On Mon, Jan 23, 2012 at 12:08 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote: There is no baked behavior for this. Create your own and override renderhead method to output js. If this is a one time thing override istemporary method to return true. -igor -igor On Jan 23, 2012 10:26 AM, Alec Swan alecs...@gmail.com wrote: It looks like your code will add an IHeaderContributor to EVERY component once IComponentOnBeforeRenderListener finds an instance of IMyPanel component. Which is not what I need. I was hoping to do something like this: addPostComponentOnBeforeRenderListener(new IComponentOnBeforeRenderListener() { @Override public void onBeforeRender(Component component) { if (component instanceof MicroSitePanel) { component.add(new XXXBehavior() { // somehow fire Javascript when component renders, e.g. onComponentTag??? }); } } }); So, my question is what XXXBehavior should I use and how to fire Javascript when component renders? Thanks, Alec On Mon, Jan 23, 2012 at 10:09 AM, Andrea Del Bene adelb...@ciseonweb.it wrote: Your idea of using PostComponentOnBeforeRenderListener sounds good to me, but I didn't understand exactly what you do with this kind of listener. Once you have checked if component implements IMyPanel, I would call Application.getHeaderContributorListenerCollection() and I would add a header contributor which renders your JavaScript as I suggested in the previous mail. The code of you IComponentOnBeforeRenderListener should be something like: implements IComponentOnBeforeRenderListener{ onBeforeRender(Component component) { if(component instanceof IMyPanel) Application.get().getHeaderContributorListenerCollection().add(new IHeaderContributor(){ public void renderHead( IHeaderResponse response) { response.renderOnLoadJavaScript(...your JavaScript...); } }); } } That's a a good idea but unfortunately my panels extend disjoint class hierarchies and I can only group them using interfaces. Any thoughts on how I can use Application listeners to accomplish this? Thanks, Alec On Mon, Jan 23, 2012 at 3:41 AM, Andrea Del Beneadelb...@ciseonweb.it wrote: - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Execute Javascript after components of a certain type render
Why not make an abstract MyPanel and provide an implementation of renderHead method (from IHeaderContributor)? I mean something like: public abstract class MyPanel extends Panel{ public void renderHead(Component component, IHeaderResponse response) { response.renderOnLoadJavaScript(...your JavaScript...); } } Hello, What is the best way to execute some Javascript code when components of type IMyPanel render? I was hoping that I could use Application#addPostComponentOnBeforeRenderListener(..) and add a listener that would add a behavior to each component of IMyPanel type. The behavior would then execute append some Javascript in onComponentTag() method. However, I can't seem to find the right type of behavior to attach or maybe I should use a different Application#addXXXListener(..) method. Please help. Thanks, Alec - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Execute Javascript after components of a certain type render
That's a a good idea but unfortunately my panels extend disjoint class hierarchies and I can only group them using interfaces. Any thoughts on how I can use Application listeners to accomplish this? Thanks, Alec On Mon, Jan 23, 2012 at 3:41 AM, Andrea Del Bene adelb...@ciseonweb.it wrote: Why not make an abstract MyPanel and provide an implementation of renderHead method (from IHeaderContributor)? I mean something like: public abstract class MyPanel extends Panel{ public void renderHead(Component component, IHeaderResponse response) { response.renderOnLoadJavaScript(...your JavaScript...); } } Hello, What is the best way to execute some Javascript code when components of type IMyPanel render? I was hoping that I could use Application#addPostComponentOnBeforeRenderListener(..) and add a listener that would add a behavior to each component of IMyPanel type. The behavior would then execute append some Javascript in onComponentTag() method. However, I can't seem to find the right type of behavior to attach or maybe I should use a different Application#addXXXListener(..) method. Please help. Thanks, Alec - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Execute Javascript after components of a certain type render
Your idea of using PostComponentOnBeforeRenderListener sounds good to me, but I didn't understand exactly what you do with this kind of listener. Once you have checked if component implements IMyPanel, I would call Application.getHeaderContributorListenerCollection() and I would add a header contributor which renders your JavaScript as I suggested in the previous mail. The code of you IComponentOnBeforeRenderListener should be something like: implements IComponentOnBeforeRenderListener{ onBeforeRender(Component component) { if(component instanceof IMyPanel) Application.get().getHeaderContributorListenerCollection().add(new IHeaderContributor(){ public void renderHead( IHeaderResponse response) { response.renderOnLoadJavaScript(...your JavaScript...); } }); } } That's a a good idea but unfortunately my panels extend disjoint class hierarchies and I can only group them using interfaces. Any thoughts on how I can use Application listeners to accomplish this? Thanks, Alec On Mon, Jan 23, 2012 at 3:41 AM, Andrea Del Beneadelb...@ciseonweb.it wrote: - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Execute Javascript after components of a certain type render
It looks like your code will add an IHeaderContributor to EVERY component once IComponentOnBeforeRenderListener finds an instance of IMyPanel component. Which is not what I need. I was hoping to do something like this: addPostComponentOnBeforeRenderListener(new IComponentOnBeforeRenderListener() { @Override public void onBeforeRender(Component component) { if (component instanceof MicroSitePanel) { component.add(new XXXBehavior() { // somehow fire Javascript when component renders, e.g. onComponentTag??? }); } } }); So, my question is what XXXBehavior should I use and how to fire Javascript when component renders? Thanks, Alec On Mon, Jan 23, 2012 at 10:09 AM, Andrea Del Bene adelb...@ciseonweb.it wrote: Your idea of using PostComponentOnBeforeRenderListener sounds good to me, but I didn't understand exactly what you do with this kind of listener. Once you have checked if component implements IMyPanel, I would call Application.getHeaderContributorListenerCollection() and I would add a header contributor which renders your JavaScript as I suggested in the previous mail. The code of you IComponentOnBeforeRenderListener should be something like: implements IComponentOnBeforeRenderListener{ onBeforeRender(Component component) { if(component instanceof IMyPanel) Application.get().getHeaderContributorListenerCollection().add(new IHeaderContributor(){ public void renderHead( IHeaderResponse response) { response.renderOnLoadJavaScript(...your JavaScript...); } }); } } That's a a good idea but unfortunately my panels extend disjoint class hierarchies and I can only group them using interfaces. Any thoughts on how I can use Application listeners to accomplish this? Thanks, Alec On Mon, Jan 23, 2012 at 3:41 AM, Andrea Del Beneadelb...@ciseonweb.it wrote: - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Execute Javascript after components of a certain type render
Sorry component instanceof MicroSitePanel should have read component instanceof IMyPanel On Mon, Jan 23, 2012 at 11:26 AM, Alec Swan alecs...@gmail.com wrote: It looks like your code will add an IHeaderContributor to EVERY component once IComponentOnBeforeRenderListener finds an instance of IMyPanel component. Which is not what I need. I was hoping to do something like this: addPostComponentOnBeforeRenderListener(new IComponentOnBeforeRenderListener() { @Override public void onBeforeRender(Component component) { if (component instanceof MicroSitePanel) { component.add(new XXXBehavior() { // somehow fire Javascript when component renders, e.g. onComponentTag??? }); } } }); So, my question is what XXXBehavior should I use and how to fire Javascript when component renders? Thanks, Alec On Mon, Jan 23, 2012 at 10:09 AM, Andrea Del Bene adelb...@ciseonweb.it wrote: Your idea of using PostComponentOnBeforeRenderListener sounds good to me, but I didn't understand exactly what you do with this kind of listener. Once you have checked if component implements IMyPanel, I would call Application.getHeaderContributorListenerCollection() and I would add a header contributor which renders your JavaScript as I suggested in the previous mail. The code of you IComponentOnBeforeRenderListener should be something like: implements IComponentOnBeforeRenderListener{ onBeforeRender(Component component) { if(component instanceof IMyPanel) Application.get().getHeaderContributorListenerCollection().add(new IHeaderContributor(){ public void renderHead( IHeaderResponse response) { response.renderOnLoadJavaScript(...your JavaScript...); } }); } } That's a a good idea but unfortunately my panels extend disjoint class hierarchies and I can only group them using interfaces. Any thoughts on how I can use Application listeners to accomplish this? Thanks, Alec On Mon, Jan 23, 2012 at 3:41 AM, Andrea Del Beneadelb...@ciseonweb.it wrote: - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Execute Javascript after components of a certain type render
There is no baked behavior for this. Create your own and override renderhead method to output js. If this is a one time thing override istemporary method to return true. -igor -igor On Jan 23, 2012 10:26 AM, Alec Swan alecs...@gmail.com wrote: It looks like your code will add an IHeaderContributor to EVERY component once IComponentOnBeforeRenderListener finds an instance of IMyPanel component. Which is not what I need. I was hoping to do something like this: addPostComponentOnBeforeRenderListener(new IComponentOnBeforeRenderListener() { @Override public void onBeforeRender(Component component) { if (component instanceof MicroSitePanel) { component.add(new XXXBehavior() { // somehow fire Javascript when component renders, e.g. onComponentTag??? }); } } }); So, my question is what XXXBehavior should I use and how to fire Javascript when component renders? Thanks, Alec On Mon, Jan 23, 2012 at 10:09 AM, Andrea Del Bene adelb...@ciseonweb.it wrote: Your idea of using PostComponentOnBeforeRenderListener sounds good to me, but I didn't understand exactly what you do with this kind of listener. Once you have checked if component implements IMyPanel, I would call Application.getHeaderContributorListenerCollection() and I would add a header contributor which renders your JavaScript as I suggested in the previous mail. The code of you IComponentOnBeforeRenderListener should be something like: implements IComponentOnBeforeRenderListener{ onBeforeRender(Component component) { if(component instanceof IMyPanel) Application.get().getHeaderContributorListenerCollection().add(new IHeaderContributor(){ public void renderHead( IHeaderResponse response) { response.renderOnLoadJavaScript(...your JavaScript...); } }); } } That's a a good idea but unfortunately my panels extend disjoint class hierarchies and I can only group them using interfaces. Any thoughts on how I can use Application listeners to accomplish this? Thanks, Alec On Mon, Jan 23, 2012 at 3:41 AM, Andrea Del Beneadelb...@ciseonweb.it wrote: - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Execute Javascript after components of a certain type render
What about AbstractTransformerBehavior? Can I use it to execute Javascript? On Mon, Jan 23, 2012 at 12:08 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote: There is no baked behavior for this. Create your own and override renderhead method to output js. If this is a one time thing override istemporary method to return true. -igor -igor On Jan 23, 2012 10:26 AM, Alec Swan alecs...@gmail.com wrote: It looks like your code will add an IHeaderContributor to EVERY component once IComponentOnBeforeRenderListener finds an instance of IMyPanel component. Which is not what I need. I was hoping to do something like this: addPostComponentOnBeforeRenderListener(new IComponentOnBeforeRenderListener() { @Override public void onBeforeRender(Component component) { if (component instanceof MicroSitePanel) { component.add(new XXXBehavior() { // somehow fire Javascript when component renders, e.g. onComponentTag??? }); } } }); So, my question is what XXXBehavior should I use and how to fire Javascript when component renders? Thanks, Alec On Mon, Jan 23, 2012 at 10:09 AM, Andrea Del Bene adelb...@ciseonweb.it wrote: Your idea of using PostComponentOnBeforeRenderListener sounds good to me, but I didn't understand exactly what you do with this kind of listener. Once you have checked if component implements IMyPanel, I would call Application.getHeaderContributorListenerCollection() and I would add a header contributor which renders your JavaScript as I suggested in the previous mail. The code of you IComponentOnBeforeRenderListener should be something like: implements IComponentOnBeforeRenderListener{ onBeforeRender(Component component) { if(component instanceof IMyPanel) Application.get().getHeaderContributorListenerCollection().add(new IHeaderContributor(){ public void renderHead( IHeaderResponse response) { response.renderOnLoadJavaScript(...your JavaScript...); } }); } } That's a a good idea but unfortunately my panels extend disjoint class hierarchies and I can only group them using interfaces. Any thoughts on how I can use Application listeners to accomplish this? Thanks, Alec On Mon, Jan 23, 2012 at 3:41 AM, Andrea Del Beneadelb...@ciseonweb.it wrote: - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org