Re: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-21 Thread Steve Swinsburg
Thanks Sven, that works nicely.

Now if only the iframe this panel loads in was in was being resized 
appropriately after the panel loads its contents

cheers,
Steve


On 21/01/2010, at 10:55 PM, Steve Swinsburg wrote:

> If it was my own Panel class then I would add the extra markup. But I am 
> using the built in AjaxLazyLoadPanel class and was hoping to just override it 
> easily.
> 
> Looks like I'll extend it as per Sven's suggestion below.
> 
> cheers,
> Steve
> 
> 
> 
> On 21/01/2010, at 6:37 PM, svenmeier wrote:
> 
>> 
>> class SomePanel extends Panel implements IHeaderContributor
>> {
>>   public SomePanel(String id)
>>   {
>>   super(id);
>>   }
>> 
>>   public void renderHead(IHeaderResponse response)
>>   {
>>   response.renderOnDomReadyJavascript("alert('hello');");
>>   }
>> }
>> 
>> Sven
>> 
>> 
>> Steve Swinsburg-3 wrote:
>>> 
>>> Hi Lionel,
>>> 
>>> Thanks and yes, thats what I am trying to do, attach some javascript after
>>> something has rendered. So I attached an AjaxEventBehaviour to it and now
>>> have this:
>>> 
>>> add(new AjaxLazyLoadPanel("myPanel") {
>>> 
>>> @Override
>>>public Component getLazyLoadComponent(String markupId) {
>>> return new SomePanel(markupId);
>>>}
>>> }.add(new AjaxEventBehavior("onload"){
>>>   protected void onEvent(AjaxRequestTarget target){
>>> target.appendJavascript("alert('hello)';");
>>>   }
>>> }));
>>> 
>>> but the javascript is never fired.
>>> 
>>> Any more ideas?
>>> 
>>> cheers,
>>> Steve
>>> 
>>> 
>>> On 21/01/2010, at 3:09 PM, Lionel Port wrote:
>>> 
>>>> Hi Steve,
>>>> 
>>>> Are you trying to do this..
>>>> 
>>>> http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html
>>>> 
>>>> with an onload event instead of onblur, or do I misunderstand.
>>>> 
>>>> regards,
>>>> Lionel
>>>> 
>>>> On Thu, Jan 21, 2010 at 2:56 PM, Steve Swinsburg
>>>>  wrote:
>>>>> So  overriding onAfterRender for a component doesn't just override it
>>>>> for that instance of the component?
>>>>> 
>>>>> Also I can see the markup is being added to the end of the page after
>>>>> the closing HTML. However, the Javadocs say it is meant to be called
>>>>> after after the actual component is finished rendering. So it look s
>>>>> like onAfterRender is not what I need.
>>>>> 
>>>>> Can I attach to a different phase in the render lifecycle to call the
>>>>> javascript when that specific panel has just finished rendering?
>>>>> 
>>>>> thanks,
>>>>> Steve
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:
>>>>> 
>>>>>> you are writing out javascript after every component render...
>>>>>> 
>>>>>> perhaps you should keep a boolean flag that marks if you rendered the
>>>>>> js yet or not.
>>>>>> 
>>>>>> alternatively you can add a behavior to the panel with istemporary() {
>>>>>> return true; }
>>>>>> 
>>>>>> -igor
>>>>>> 
>>>>>> On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
>>>>>>  wrote:
>>>>>>> I have an AjaxLazyLoadPanel and want some javascript to fire after its
>>>>>>> loaded it's contents:
>>>>>>> 
>>>>>>> I assumed I could override onAfterRender and add my javascript like
>>>>>>> so:
>>>>>>> 
>>>>>>> add(new AjaxLazyLoadPanel("myPanel") {
>>>>>>> 
>>>>>>>  @Override
>>>>>>>  public Component getLazyLoadComponent(String markupId) {
>>>>>>>  return new SomePamel(markupId);
>>>>>>>  }
>>>>>>> 
>>>>>>>  @Override
>>>>>>>  protected void onAfterRender() {
>>

Re: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-21 Thread Steve Swinsburg
If it was my own Panel class then I would add the extra markup. But I am using 
the built in AjaxLazyLoadPanel class and was hoping to just override it easily.

Looks like I'll extend it as per Sven's suggestion below.

cheers,
Steve



On 21/01/2010, at 6:37 PM, svenmeier wrote:

> 
> class SomePanel extends Panel implements IHeaderContributor
> {
>public SomePanel(String id)
>{
>super(id);
>}
> 
>public void renderHead(IHeaderResponse response)
>{
>response.renderOnDomReadyJavascript("alert('hello');");
>}
> }
> 
> Sven
> 
> 
> Steve Swinsburg-3 wrote:
>> 
>> Hi Lionel,
>> 
>> Thanks and yes, thats what I am trying to do, attach some javascript after
>> something has rendered. So I attached an AjaxEventBehaviour to it and now
>> have this:
>> 
>> add(new AjaxLazyLoadPanel("myPanel") {
>> 
>>  @Override
>> public Component getLazyLoadComponent(String markupId) {
>>  return new SomePanel(markupId);
>> }
>> }.add(new AjaxEventBehavior("onload"){
>>protected void onEvent(AjaxRequestTarget target){
>>  target.appendJavascript("alert('hello)';");
>>}
>> }));
>> 
>> but the javascript is never fired.
>> 
>> Any more ideas?
>> 
>> cheers,
>> Steve
>> 
>> 
>> On 21/01/2010, at 3:09 PM, Lionel Port wrote:
>> 
>>> Hi Steve,
>>> 
>>> Are you trying to do this..
>>> 
>>> http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html
>>> 
>>> with an onload event instead of onblur, or do I misunderstand.
>>> 
>>> regards,
>>> Lionel
>>> 
>>> On Thu, Jan 21, 2010 at 2:56 PM, Steve Swinsburg
>>>  wrote:
>>>> So  overriding onAfterRender for a component doesn't just override it
>>>> for that instance of the component?
>>>> 
>>>> Also I can see the markup is being added to the end of the page after
>>>> the closing HTML. However, the Javadocs say it is meant to be called
>>>> after after the actual component is finished rendering. So it look s
>>>> like onAfterRender is not what I need.
>>>> 
>>>> Can I attach to a different phase in the render lifecycle to call the
>>>> javascript when that specific panel has just finished rendering?
>>>> 
>>>> thanks,
>>>> Steve
>>>> 
>>>> 
>>>> 
>>>> 
>>>> On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:
>>>> 
>>>>> you are writing out javascript after every component render...
>>>>> 
>>>>> perhaps you should keep a boolean flag that marks if you rendered the
>>>>> js yet or not.
>>>>> 
>>>>> alternatively you can add a behavior to the panel with istemporary() {
>>>>> return true; }
>>>>> 
>>>>> -igor
>>>>> 
>>>>> On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
>>>>>  wrote:
>>>>>> I have an AjaxLazyLoadPanel and want some javascript to fire after its
>>>>>> loaded it's contents:
>>>>>> 
>>>>>> I assumed I could override onAfterRender and add my javascript like
>>>>>> so:
>>>>>> 
>>>>>> add(new AjaxLazyLoadPanel("myPanel") {
>>>>>> 
>>>>>>   @Override
>>>>>>   public Component getLazyLoadComponent(String markupId) {
>>>>>>   return new SomePamel(markupId);
>>>>>>   }
>>>>>> 
>>>>>>   @Override
>>>>>>   protected void onAfterRender() {
>>>>>>   JavascriptUtils.writeJavascript(getResponse(),
>>>>>> "alert('hello');");
>>>>>>   super.onAfterRender();
>>>>>>   }
>>>>>> 
>>>>>> });
>>>>>> 
>>>>>> Except it is called twice, it looks like once when the page is loading
>>>>>> and then again when the actual panel has been loaded.
>>>>>> 
>>>>>> Is there another way to achieve what I want?
>>>>>> 
>>>>>> thanks,
>>>>>> Steve
>>>>>> 
>>>>>> 
>>>>> 
>>>>> -
>>>>> 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
>>> 
>> 
>> 
>> 
> 
> -- 
> View this message in context: 
> http://old.nabble.com/onAfterRender-called-twice-in-AjaxLazyLoadPanel-tp27252299p27253924.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 



smime.p7s
Description: S/MIME cryptographic signature


Re: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-20 Thread svenmeier

class SomePanel extends Panel implements IHeaderContributor
{
public SomePanel(String id)
{
super(id);
}
 
public void renderHead(IHeaderResponse response)
{
response.renderOnDomReadyJavascript("alert('hello');");
}
}
 
Sven


Steve Swinsburg-3 wrote:
> 
> Hi Lionel,
> 
> Thanks and yes, thats what I am trying to do, attach some javascript after
> something has rendered. So I attached an AjaxEventBehaviour to it and now
> have this:
> 
> add(new AjaxLazyLoadPanel("myPanel") {
> 
>   @Override
>  public Component getLazyLoadComponent(String markupId) {
>   return new SomePanel(markupId);
>  }
> }.add(new AjaxEventBehavior("onload"){
> protected void onEvent(AjaxRequestTarget target){
>   target.appendJavascript("alert('hello)';");
> }
> }));
> 
> but the javascript is never fired.
> 
> Any more ideas?
> 
> cheers,
> Steve
> 
> 
> On 21/01/2010, at 3:09 PM, Lionel Port wrote:
> 
>> Hi Steve,
>> 
>> Are you trying to do this..
>> 
>> http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html
>> 
>> with an onload event instead of onblur, or do I misunderstand.
>> 
>> regards,
>> Lionel
>> 
>> On Thu, Jan 21, 2010 at 2:56 PM, Steve Swinsburg
>>  wrote:
>>> So  overriding onAfterRender for a component doesn't just override it
>>> for that instance of the component?
>>> 
>>> Also I can see the markup is being added to the end of the page after
>>> the closing HTML. However, the Javadocs say it is meant to be called
>>> after after the actual component is finished rendering. So it look s
>>> like onAfterRender is not what I need.
>>> 
>>> Can I attach to a different phase in the render lifecycle to call the
>>> javascript when that specific panel has just finished rendering?
>>> 
>>> thanks,
>>> Steve
>>> 
>>> 
>>> 
>>> 
>>> On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:
>>> 
>>>> you are writing out javascript after every component render...
>>>> 
>>>> perhaps you should keep a boolean flag that marks if you rendered the
>>>> js yet or not.
>>>> 
>>>> alternatively you can add a behavior to the panel with istemporary() {
>>>> return true; }
>>>> 
>>>> -igor
>>>> 
>>>> On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
>>>>  wrote:
>>>>> I have an AjaxLazyLoadPanel and want some javascript to fire after its
>>>>> loaded it's contents:
>>>>> 
>>>>> I assumed I could override onAfterRender and add my javascript like
>>>>> so:
>>>>> 
>>>>> add(new AjaxLazyLoadPanel("myPanel") {
>>>>> 
>>>>>@Override
>>>>>public Component getLazyLoadComponent(String markupId) {
>>>>>return new SomePamel(markupId);
>>>>>}
>>>>> 
>>>>>@Override
>>>>>protected void onAfterRender() {
>>>>>JavascriptUtils.writeJavascript(getResponse(),
>>>>> "alert('hello');");
>>>>>super.onAfterRender();
>>>>>}
>>>>> 
>>>>> });
>>>>> 
>>>>> Except it is called twice, it looks like once when the page is loading
>>>>> and then again when the actual panel has been loaded.
>>>>> 
>>>>> Is there another way to achieve what I want?
>>>>> 
>>>>> thanks,
>>>>> Steve
>>>>> 
>>>>> 
>>>> 
>>>> -
>>>> 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
>> 
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/onAfterRender-called-twice-in-AjaxLazyLoadPanel-tp27252299p27253924.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-20 Thread Lionel Port
Actually, Ernesto idea sounds much simpler.

On Thu, Jan 21, 2010 at 4:19 PM, Ernesto Reinaldo Barreiro
 wrote:
> Why don't you include a 

Re: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-20 Thread Ernesto Reinaldo Barreiro
Why don't you include a 

Re: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-20 Thread Steve Swinsburg
Ah. Ok added that, still nothing. I see in the markup that the html has been 
added to the panel's div, though it's not running. Elsewhere on the page 
Javascript is working ok so I don't think it's broken, I just don't think the 
onLoad event is firing for an AjaxLazyLoadPanel.

I'll keep going with these behaviours though, if thats how it should be 
implemented?

cheers for the tips,
Steve




On 21/01/2010, at 3:38 PM, Lionel Port wrote:

> I was looking at the first box.
> 
> add(new AbstractDefaultAjaxBehavior() {
>   @Override
>   protected void onComponentTag(ComponentTag tag) {
>   super.onComponentTag(tag);
>   String js = "alert('hello');";
>   tag.put("onload", js);
>   }
> }
> 
> On Thu, Jan 21, 2010 at 3:31 PM, Steve Swinsburg
>  wrote:
>> Typo in the alert, but even adding logging to the AjaxEventBehavior, it 
>> never fires.
>> 
>> .add(new AjaxEventBehavior("onload"){
>>protected void onEvent(AjaxRequestTarget target){
>>log.error("*");
>>target.appendJavascript("alert('hello');");
>>}
>>}));
>> 
>> logs show nothing.
>> 
>> Is it because its loading asynchronously after the rest of the page loads? 
>> If so, how can I tap into it?
>> 
>> cheers.
>> 
>> 
>> On 21/01/2010, at 3:26 PM, Steve Swinsburg wrote:
>> 
>>> Hi Lionel,
>>> 
>>> Thanks and yes, thats what I am trying to do, attach some javascript after 
>>> something has rendered. So I attached an AjaxEventBehaviour to it and now 
>>> have this:
>>> 
>>> add(new AjaxLazyLoadPanel("myPanel") {
>>> 
>>>   @Override
>>>  public Component getLazyLoadComponent(String markupId) {
>>>   return new SomePanel(markupId);
>>>  }
>>> }.add(new AjaxEventBehavior("onload"){
>>> protected void onEvent(AjaxRequestTarget target){
>>>   target.appendJavascript("alert('hello)';");
>>> }
>>> }));
>>> 
>>> but the javascript is never fired.
>>> 
>>> Any more ideas?
>>> 
>>> cheers,
>>> Steve
>>> 
>>> 
>>> On 21/01/2010, at 3:09 PM, Lionel Port wrote:
>>> 
 Hi Steve,
 
 Are you trying to do this..
 
 http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html
 
 with an onload event instead of onblur, or do I misunderstand.
 
 regards,
 Lionel
 
 On Thu, Jan 21, 2010 at 2:56 PM, Steve Swinsburg
  wrote:
> So  overriding onAfterRender for a component doesn't just override it for 
> that instance of the component?
> 
> Also I can see the markup is being added to the end of the page after the 
> closing HTML. However, the Javadocs say it is meant to be called after 
> after the actual component is finished rendering. So it look s like 
> onAfterRender is not what I need.
> 
> Can I attach to a different phase in the render lifecycle to call the 
> javascript when that specific panel has just finished rendering?
> 
> thanks,
> Steve
> 
> 
> 
> 
> On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:
> 
>> you are writing out javascript after every component render...
>> 
>> perhaps you should keep a boolean flag that marks if you rendered the
>> js yet or not.
>> 
>> alternatively you can add a behavior to the panel with istemporary() {
>> return true; }
>> 
>> -igor
>> 
>> On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
>>  wrote:
>>> I have an AjaxLazyLoadPanel and want some javascript to fire after its 
>>> loaded it's contents:
>>> 
>>> I assumed I could override onAfterRender and add my javascript like so:
>>> 
>>> add(new AjaxLazyLoadPanel("myPanel") {
>>> 
>>>@Override
>>>public Component getLazyLoadComponent(String markupId) {
>>>return new SomePamel(markupId);
>>>}
>>> 
>>>@Override
>>>protected void onAfterRender() {
>>>JavascriptUtils.writeJavascript(getResponse(), 
>>> "alert('hello');");
>>>super.onAfterRender();
>>>}
>>> 
>>> });
>>> 
>>> Except it is called twice, it looks like once when the page is loading 
>>> and then again when the actual panel has been loaded.
>>> 
>>> Is there another way to achieve what I want?
>>> 
>>> thanks,
>>> Steve
>>> 
>>> 
>> 
>> -
>> 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.ap

Re: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-20 Thread Lionel Port
I guess doesn't need to extend AjaxBehaviour as it doesn't have any ajax.

Try.

add(new AbstractBehavior() {
   @Override
   protected void onComponentTag(ComponentTag tag) {
   super.onComponentTag(tag);
   String js = "alert('hello');";
   tag.put("onload", js);
   }
}


On Thu, Jan 21, 2010 at 3:38 PM, Lionel Port  wrote:
> I was looking at the first box.
>
> add(new AbstractDefaultAjaxBehavior() {
>               �...@override
>                protected void onComponentTag(ComponentTag tag) {
>                        super.onComponentTag(tag);
>                        String js = "alert('hello');";
>                        tag.put("onload", js);
>                }
> }
>
> On Thu, Jan 21, 2010 at 3:31 PM, Steve Swinsburg
>  wrote:
>> Typo in the alert, but even adding logging to the AjaxEventBehavior, it 
>> never fires.
>>
>> .add(new AjaxEventBehavior("onload"){
>>                protected void onEvent(AjaxRequestTarget target){
>>                        log.error("*");
>>                        target.appendJavascript("alert('hello');");
>>                }
>>        }));
>>
>> logs show nothing.
>>
>> Is it because its loading asynchronously after the rest of the page loads? 
>> If so, how can I tap into it?
>>
>> cheers.
>>
>>
>> On 21/01/2010, at 3:26 PM, Steve Swinsburg wrote:
>>
>>> Hi Lionel,
>>>
>>> Thanks and yes, thats what I am trying to do, attach some javascript after 
>>> something has rendered. So I attached an AjaxEventBehaviour to it and now 
>>> have this:
>>>
>>> add(new AjaxLazyLoadPanel("myPanel") {
>>>
>>>       @Override
>>>          public Component getLazyLoadComponent(String markupId) {
>>>               return new SomePanel(markupId);
>>>          }
>>> }.add(new AjaxEventBehavior("onload"){
>>>         protected void onEvent(AjaxRequestTarget target){
>>>               target.appendJavascript("alert('hello)';");
>>>         }
>>> }));
>>>
>>> but the javascript is never fired.
>>>
>>> Any more ideas?
>>>
>>> cheers,
>>> Steve
>>>
>>>
>>> On 21/01/2010, at 3:09 PM, Lionel Port wrote:
>>>
 Hi Steve,

 Are you trying to do this..

 http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html

 with an onload event instead of onblur, or do I misunderstand.

 regards,
 Lionel

 On Thu, Jan 21, 2010 at 2:56 PM, Steve Swinsburg
  wrote:
> So  overriding onAfterRender for a component doesn't just override it for 
> that instance of the component?
>
> Also I can see the markup is being added to the end of the page after the 
> closing HTML. However, the Javadocs say it is meant to be called after 
> after the actual component is finished rendering. So it look s like 
> onAfterRender is not what I need.
>
> Can I attach to a different phase in the render lifecycle to call the 
> javascript when that specific panel has just finished rendering?
>
> thanks,
> Steve
>
>
>
>
> On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:
>
>> you are writing out javascript after every component render...
>>
>> perhaps you should keep a boolean flag that marks if you rendered the
>> js yet or not.
>>
>> alternatively you can add a behavior to the panel with istemporary() {
>> return true; }
>>
>> -igor
>>
>> On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
>>  wrote:
>>> I have an AjaxLazyLoadPanel and want some javascript to fire after its 
>>> loaded it's contents:
>>>
>>> I assumed I could override onAfterRender and add my javascript like so:
>>>
>>> add(new AjaxLazyLoadPanel("myPanel") {
>>>
>>>       �...@override
>>>        public Component getLazyLoadComponent(String markupId) {
>>>            return new SomePamel(markupId);
>>>        }
>>>
>>>       �...@override
>>>        protected void onAfterRender() {
>>>                JavascriptUtils.writeJavascript(getResponse(), 
>>> "alert('hello');");
>>>                super.onAfterRender();
>>>        }
>>>
>>> });
>>>
>>> Except it is called twice, it looks like once when the page is loading 
>>> and then again when the actual panel has been loaded.
>>>
>>> Is there another way to achieve what I want?
>>>
>>> thanks,
>>> Steve
>>>
>>>
>>
>> -
>> 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: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-20 Thread Lionel Port
I was looking at the first box.

add(new AbstractDefaultAjaxBehavior() {
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
String js = "alert('hello');";
tag.put("onload", js);
}
}

On Thu, Jan 21, 2010 at 3:31 PM, Steve Swinsburg
 wrote:
> Typo in the alert, but even adding logging to the AjaxEventBehavior, it never 
> fires.
>
> .add(new AjaxEventBehavior("onload"){
>                protected void onEvent(AjaxRequestTarget target){
>                        log.error("*");
>                        target.appendJavascript("alert('hello');");
>                }
>        }));
>
> logs show nothing.
>
> Is it because its loading asynchronously after the rest of the page loads? If 
> so, how can I tap into it?
>
> cheers.
>
>
> On 21/01/2010, at 3:26 PM, Steve Swinsburg wrote:
>
>> Hi Lionel,
>>
>> Thanks and yes, thats what I am trying to do, attach some javascript after 
>> something has rendered. So I attached an AjaxEventBehaviour to it and now 
>> have this:
>>
>> add(new AjaxLazyLoadPanel("myPanel") {
>>
>>       @Override
>>          public Component getLazyLoadComponent(String markupId) {
>>               return new SomePanel(markupId);
>>          }
>> }.add(new AjaxEventBehavior("onload"){
>>         protected void onEvent(AjaxRequestTarget target){
>>               target.appendJavascript("alert('hello)';");
>>         }
>> }));
>>
>> but the javascript is never fired.
>>
>> Any more ideas?
>>
>> cheers,
>> Steve
>>
>>
>> On 21/01/2010, at 3:09 PM, Lionel Port wrote:
>>
>>> Hi Steve,
>>>
>>> Are you trying to do this..
>>>
>>> http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html
>>>
>>> with an onload event instead of onblur, or do I misunderstand.
>>>
>>> regards,
>>> Lionel
>>>
>>> On Thu, Jan 21, 2010 at 2:56 PM, Steve Swinsburg
>>>  wrote:
 So  overriding onAfterRender for a component doesn't just override it for 
 that instance of the component?

 Also I can see the markup is being added to the end of the page after the 
 closing HTML. However, the Javadocs say it is meant to be called after 
 after the actual component is finished rendering. So it look s like 
 onAfterRender is not what I need.

 Can I attach to a different phase in the render lifecycle to call the 
 javascript when that specific panel has just finished rendering?

 thanks,
 Steve




 On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:

> you are writing out javascript after every component render...
>
> perhaps you should keep a boolean flag that marks if you rendered the
> js yet or not.
>
> alternatively you can add a behavior to the panel with istemporary() {
> return true; }
>
> -igor
>
> On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
>  wrote:
>> I have an AjaxLazyLoadPanel and want some javascript to fire after its 
>> loaded it's contents:
>>
>> I assumed I could override onAfterRender and add my javascript like so:
>>
>> add(new AjaxLazyLoadPanel("myPanel") {
>>
>>       �...@override
>>        public Component getLazyLoadComponent(String markupId) {
>>            return new SomePamel(markupId);
>>        }
>>
>>       �...@override
>>        protected void onAfterRender() {
>>                JavascriptUtils.writeJavascript(getResponse(), 
>> "alert('hello');");
>>                super.onAfterRender();
>>        }
>>
>> });
>>
>> Except it is called twice, it looks like once when the page is loading 
>> and then again when the actual panel has been loaded.
>>
>> Is there another way to achieve what I want?
>>
>> thanks,
>> Steve
>>
>>
>
> -
> 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
>>>
>>
>
>

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



Re: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-20 Thread Steve Swinsburg
Typo in the alert, but even adding logging to the AjaxEventBehavior, it never 
fires.

.add(new AjaxEventBehavior("onload"){
protected void onEvent(AjaxRequestTarget target){
log.error("*");
target.appendJavascript("alert('hello');");
}
}));

logs show nothing.

Is it because its loading asynchronously after the rest of the page loads? If 
so, how can I tap into it?

cheers.


On 21/01/2010, at 3:26 PM, Steve Swinsburg wrote:

> Hi Lionel,
> 
> Thanks and yes, thats what I am trying to do, attach some javascript after 
> something has rendered. So I attached an AjaxEventBehaviour to it and now 
> have this:
> 
> add(new AjaxLazyLoadPanel("myPanel") {
> 
>   @Override
>  public Component getLazyLoadComponent(String markupId) {
>   return new SomePanel(markupId);
>  }
> }.add(new AjaxEventBehavior("onload"){
> protected void onEvent(AjaxRequestTarget target){
>   target.appendJavascript("alert('hello)';");
> }
> }));
> 
> but the javascript is never fired.
> 
> Any more ideas?
> 
> cheers,
> Steve
> 
> 
> On 21/01/2010, at 3:09 PM, Lionel Port wrote:
> 
>> Hi Steve,
>> 
>> Are you trying to do this..
>> 
>> http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html
>> 
>> with an onload event instead of onblur, or do I misunderstand.
>> 
>> regards,
>> Lionel
>> 
>> On Thu, Jan 21, 2010 at 2:56 PM, Steve Swinsburg
>>  wrote:
>>> So  overriding onAfterRender for a component doesn't just override it for 
>>> that instance of the component?
>>> 
>>> Also I can see the markup is being added to the end of the page after the 
>>> closing HTML. However, the Javadocs say it is meant to be called after 
>>> after the actual component is finished rendering. So it look s like 
>>> onAfterRender is not what I need.
>>> 
>>> Can I attach to a different phase in the render lifecycle to call the 
>>> javascript when that specific panel has just finished rendering?
>>> 
>>> thanks,
>>> Steve
>>> 
>>> 
>>> 
>>> 
>>> On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:
>>> 
 you are writing out javascript after every component render...
 
 perhaps you should keep a boolean flag that marks if you rendered the
 js yet or not.
 
 alternatively you can add a behavior to the panel with istemporary() {
 return true; }
 
 -igor
 
 On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
  wrote:
> I have an AjaxLazyLoadPanel and want some javascript to fire after its 
> loaded it's contents:
> 
> I assumed I could override onAfterRender and add my javascript like so:
> 
> add(new AjaxLazyLoadPanel("myPanel") {
> 
>@Override
>public Component getLazyLoadComponent(String markupId) {
>return new SomePamel(markupId);
>}
> 
>@Override
>protected void onAfterRender() {
>JavascriptUtils.writeJavascript(getResponse(), 
> "alert('hello');");
>super.onAfterRender();
>}
> 
> });
> 
> Except it is called twice, it looks like once when the page is loading 
> and then again when the actual panel has been loaded.
> 
> Is there another way to achieve what I want?
> 
> thanks,
> Steve
> 
> 
 
 -
 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: add javascript after AjaxLazyLoadPanel finishes rendering - (was: onAfterRender called twice in AjaxLazyLoadPanel)

2010-01-20 Thread Steve Swinsburg
Hi Lionel,

Thanks and yes, thats what I am trying to do, attach some javascript after 
something has rendered. So I attached an AjaxEventBehaviour to it and now have 
this:

add(new AjaxLazyLoadPanel("myPanel") {

@Override
 public Component getLazyLoadComponent(String markupId) {
return new SomePanel(markupId);
 }
}.add(new AjaxEventBehavior("onload"){
protected void onEvent(AjaxRequestTarget target){
target.appendJavascript("alert('hello)';");
}
}));

but the javascript is never fired.

Any more ideas?

cheers,
Steve


On 21/01/2010, at 3:09 PM, Lionel Port wrote:

> Hi Steve,
> 
> Are you trying to do this..
> 
> http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html
> 
> with an onload event instead of onblur, or do I misunderstand.
> 
> regards,
> Lionel
> 
> On Thu, Jan 21, 2010 at 2:56 PM, Steve Swinsburg
>  wrote:
>> So  overriding onAfterRender for a component doesn't just override it for 
>> that instance of the component?
>> 
>> Also I can see the markup is being added to the end of the page after the 
>> closing HTML. However, the Javadocs say it is meant to be called after after 
>> the actual component is finished rendering. So it look s like onAfterRender 
>> is not what I need.
>> 
>> Can I attach to a different phase in the render lifecycle to call the 
>> javascript when that specific panel has just finished rendering?
>> 
>> thanks,
>> Steve
>> 
>> 
>> 
>> 
>> On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:
>> 
>>> you are writing out javascript after every component render...
>>> 
>>> perhaps you should keep a boolean flag that marks if you rendered the
>>> js yet or not.
>>> 
>>> alternatively you can add a behavior to the panel with istemporary() {
>>> return true; }
>>> 
>>> -igor
>>> 
>>> On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
>>>  wrote:
 I have an AjaxLazyLoadPanel and want some javascript to fire after its 
 loaded it's contents:
 
 I assumed I could override onAfterRender and add my javascript like so:
 
 add(new AjaxLazyLoadPanel("myPanel") {
 
@Override
public Component getLazyLoadComponent(String markupId) {
return new SomePamel(markupId);
}
 
@Override
protected void onAfterRender() {
JavascriptUtils.writeJavascript(getResponse(), 
 "alert('hello');");
super.onAfterRender();
}
 
 });
 
 Except it is called twice, it looks like once when the page is loading and 
 then again when the actual panel has been loaded.
 
 Is there another way to achieve what I want?
 
 thanks,
 Steve
 
 
>>> 
>>> -
>>> 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: onAfterRender called twice in AjaxLazyLoadPanel

2010-01-20 Thread Lionel Port
Hi Steve,

Are you trying to do this..

http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html

with an onload event instead of onblur, or do I misunderstand.

regards,
Lionel

On Thu, Jan 21, 2010 at 2:56 PM, Steve Swinsburg
 wrote:
> So  overriding onAfterRender for a component doesn't just override it for 
> that instance of the component?
>
> Also I can see the markup is being added to the end of the page after the 
> closing HTML. However, the Javadocs say it is meant to be called after after 
> the actual component is finished rendering. So it look s like onAfterRender 
> is not what I need.
>
> Can I attach to a different phase in the render lifecycle to call the 
> javascript when that specific panel has just finished rendering?
>
> thanks,
> Steve
>
>
>
>
> On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:
>
>> you are writing out javascript after every component render...
>>
>> perhaps you should keep a boolean flag that marks if you rendered the
>> js yet or not.
>>
>> alternatively you can add a behavior to the panel with istemporary() {
>> return true; }
>>
>> -igor
>>
>> On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
>>  wrote:
>>> I have an AjaxLazyLoadPanel and want some javascript to fire after its 
>>> loaded it's contents:
>>>
>>> I assumed I could override onAfterRender and add my javascript like so:
>>>
>>> add(new AjaxLazyLoadPanel("myPanel") {
>>>
>>>       �...@override
>>>        public Component getLazyLoadComponent(String markupId) {
>>>            return new SomePamel(markupId);
>>>        }
>>>
>>>       �...@override
>>>        protected void onAfterRender() {
>>>                JavascriptUtils.writeJavascript(getResponse(), 
>>> "alert('hello');");
>>>                super.onAfterRender();
>>>        }
>>>
>>> });
>>>
>>> Except it is called twice, it looks like once when the page is loading and 
>>> then again when the actual panel has been loaded.
>>>
>>> Is there another way to achieve what I want?
>>>
>>> thanks,
>>> Steve
>>>
>>>
>>
>> -
>> 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: onAfterRender called twice in AjaxLazyLoadPanel

2010-01-20 Thread Steve Swinsburg
So  overriding onAfterRender for a component doesn't just override it for that 
instance of the component? 

Also I can see the markup is being added to the end of the page after the 
closing HTML. However, the Javadocs say it is meant to be called after after 
the actual component is finished rendering. So it look s like onAfterRender is 
not what I need.

Can I attach to a different phase in the render lifecycle to call the 
javascript when that specific panel has just finished rendering?

thanks,
Steve




On 21/01/2010, at 2:52 PM, Igor Vaynberg wrote:

> you are writing out javascript after every component render...
> 
> perhaps you should keep a boolean flag that marks if you rendered the
> js yet or not.
> 
> alternatively you can add a behavior to the panel with istemporary() {
> return true; }
> 
> -igor
> 
> On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
>  wrote:
>> I have an AjaxLazyLoadPanel and want some javascript to fire after its 
>> loaded it's contents:
>> 
>> I assumed I could override onAfterRender and add my javascript like so:
>> 
>> add(new AjaxLazyLoadPanel("myPanel") {
>> 
>>@Override
>>public Component getLazyLoadComponent(String markupId) {
>>return new SomePamel(markupId);
>>}
>> 
>>@Override
>>protected void onAfterRender() {
>>JavascriptUtils.writeJavascript(getResponse(), 
>> "alert('hello');");
>>super.onAfterRender();
>>}
>> 
>> });
>> 
>> Except it is called twice, it looks like once when the page is loading and 
>> then again when the actual panel has been loaded.
>> 
>> Is there another way to achieve what I want?
>> 
>> thanks,
>> Steve
>> 
>> 
> 
> -
> 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: onAfterRender called twice in AjaxLazyLoadPanel

2010-01-20 Thread Igor Vaynberg
you are writing out javascript after every component render...

perhaps you should keep a boolean flag that marks if you rendered the
js yet or not.

alternatively you can add a behavior to the panel with istemporary() {
return true; }

-igor

On Wed, Jan 20, 2010 at 7:24 PM, Steve Swinsburg
 wrote:
> I have an AjaxLazyLoadPanel and want some javascript to fire after its loaded 
> it's contents:
>
> I assumed I could override onAfterRender and add my javascript like so:
>
> add(new AjaxLazyLoadPanel("myPanel") {
>
>       �...@override
>        public Component getLazyLoadComponent(String markupId) {
>            return new SomePamel(markupId);
>        }
>
>       �...@override
>        protected void onAfterRender() {
>                JavascriptUtils.writeJavascript(getResponse(), 
> "alert('hello');");
>                super.onAfterRender();
>        }
>
> });
>
> Except it is called twice, it looks like once when the page is loading and 
> then again when the actual panel has been loaded.
>
> Is there another way to achieve what I want?
>
> thanks,
> Steve
>
>

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



onAfterRender called twice in AjaxLazyLoadPanel

2010-01-20 Thread Steve Swinsburg
I have an AjaxLazyLoadPanel and want some javascript to fire after its loaded 
it's contents:

I assumed I could override onAfterRender and add my javascript like so:

add(new AjaxLazyLoadPanel("myPanel") {

@Override
public Component getLazyLoadComponent(String markupId) {
return new SomePamel(markupId);
}

@Override
protected void onAfterRender() {
JavascriptUtils.writeJavascript(getResponse(), 
"alert('hello');");
super.onAfterRender();
}

});

Except it is called twice, it looks like once when the page is loading and then 
again when the actual panel has been loaded.

Is there another way to achieve what I want?

thanks,
Steve