Wicket 1.5: Question (or feature request) afterOnInitialize()

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Wicket 1.5: Question (or feature request) afterOnInitialize()

armandoxxx
Hey guys ...

With wicket 1.5 we got events. So far so good but I got a case where i'm missing after on initialize method call.

I have lot's of panels on my page, and I create them in onInitialize() code. But I need to send a 1 time event after all components are initialized.
- problem #1: If I send an event from onInitialize():  not sure that all components are initialized !
- problem #2: If is send an event from onConfigure() or onBeforeRender(), the event get send everytime component is rendered ...

So current solution is to create a flag in my panels that sendEventOnInit() method was allready called ..

but it would be better  to have a method onInitialized() | afterInitialized() (pick your favorite name).

If someone has better approach, please let me know about it !

Kind regards

Armando
Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Pedro Santos
Hi Armando, the problem #1 is rather about not have the entire
component tree connected already. onInitialize is called when the
component is aware of its path to page, at this moment, a triggered
even will not reach new nodes addition in the component tree.

On Wed, Aug 10, 2011 at 7:23 AM, armandoxxx <[hidden email]> wrote:

> Hey guys ...
>
> With wicket 1.5 we got events. So far so good but I got a case where i'm
> missing after on initialize method call.
>
> I have lot's of panels on my page, and I create them in onInitialize() code.
> But I need to send a 1 time event after all components are initialized.
> - problem #1: If I send an event from onInitialize():  not sure that all
> components are initialized !
> - problem #2: If is send an event from onConfigure() or onBeforeRender(),
> the event get send everytime component is rendered ...
>
> So current solution is to create a flag in my panels that sendEventOnInit()
> method was allready called ..
>
> but it would be better  to have a method onInitialized() |
> afterInitialized() (pick your favorite name).
>
> If someone has better approach, please let me know about it !
>
> Kind regards
>
> Armando
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3732520.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Pedro Henrique Oliveira dos Santos

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Martin Grigorov-4
In reply to this post by armandoxxx
You almost found it yourself.
Use onBeforeRender() + hasBeenRendered() instead of your custom flag.


On Wed, Aug 10, 2011 at 1:23 PM, armandoxxx <[hidden email]> wrote:

> Hey guys ...
>
> With wicket 1.5 we got events. So far so good but I got a case where i'm
> missing after on initialize method call.
>
> I have lot's of panels on my page, and I create them in onInitialize() code.
> But I need to send a 1 time event after all components are initialized.
> - problem #1: If I send an event from onInitialize():  not sure that all
> components are initialized !
> - problem #2: If is send an event from onConfigure() or onBeforeRender(),
> the event get send everytime component is rendered ...
>
> So current solution is to create a flag in my panels that sendEventOnInit()
> method was allready called ..
>
> but it would be better  to have a method onInitialized() |
> afterInitialized() (pick your favorite name).
>
> If someone has better approach, please let me know about it !
>
> Kind regards
>
> Armando
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3732520.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

armandoxxx
In reply to this post by Pedro Santos
@pedro I know. That's why I didn't put the event call in onInitialize() method ;)

@martin: I if use on before render .. my event would be triggered everytime my component renders .. so if I want 1 time event after the component is initialized I have to use somekind of a flag for this event to be called just once. So that's why I suggested afterInitialized() method ;)

thank you guys for responses

Regards

Armando
Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Igor Vaynberg-2
In reply to this post by armandoxxx
we cant keep building these things because eventually someone will ask
for onAfterAfterInitialized() and so on. what we can do is make it
easy for you to build your own. you can create your own
IComponentOnBeforeRenderListener that checks if the component being
rendered is a page and if it is visits all the children and invokes
your callback if it hasnt been already invoked. you can keep track of
whether or not its been invoked by using component metadata.

-igor


On Wed, Aug 10, 2011 at 3:23 AM, armandoxxx <[hidden email]> wrote:

> Hey guys ...
>
> With wicket 1.5 we got events. So far so good but I got a case where i'm
> missing after on initialize method call.
>
> I have lot's of panels on my page, and I create them in onInitialize() code.
> But I need to send a 1 time event after all components are initialized.
> - problem #1: If I send an event from onInitialize():  not sure that all
> components are initialized !
> - problem #2: If is send an event from onConfigure() or onBeforeRender(),
> the event get send everytime component is rendered ...
>
> So current solution is to create a flag in my panels that sendEventOnInit()
> method was allready called ..
>
> but it would be better  to have a method onInitialized() |
> afterInitialized() (pick your favorite name).
>
> If someone has better approach, please let me know about it !
>
> Kind regards
>
> Armando
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3732520.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Martin Grigorov-4
In reply to this post by armandoxxx
MyPage.java:
protected void onBeforeRender() {

        if (!hasBeenRendered()) {
            send(...);
        }

        super.onBeforeRender();
    }

On Wed, Aug 10, 2011 at 8:18 PM, armandoxxx <[hidden email]> wrote:

> @pedro I know. That's why I didn't put the event call in onInitialize()
> method ;)
>
> @martin: I if use on before render .. my event would be triggered everytime
> my component renders .. so if I want 1 time event after the component is
> initialized I have to use somekind of a flag for this event to be called
> just once. So that's why I suggested afterInitialized() method ;)
>
> thank you guys for responses
>
> Regards
>
> Armando
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3733649.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Igor Vaynberg-2
this will get called more than once for a component that starts out
and remains invisible for a while.

-igor


On Wed, Aug 10, 2011 at 10:25 AM, Martin Grigorov <[hidden email]> wrote:

> MyPage.java:
> protected void onBeforeRender() {
>
>        if (!hasBeenRendered()) {
>            send(...);
>        }
>
>        super.onBeforeRender();
>    }
>
> On Wed, Aug 10, 2011 at 8:18 PM, armandoxxx <[hidden email]> wrote:
>> @pedro I know. That's why I didn't put the event call in onInitialize()
>> method ;)
>>
>> @martin: I if use on before render .. my event would be triggered everytime
>> my component renders .. so if I want 1 time event after the component is
>> initialized I have to use somekind of a flag for this event to be called
>> just once. So that's why I suggested afterInitialized() method ;)
>>
>> thank you guys for responses
>>
>> Regards
>>
>> Armando
>>
>> --
>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3733649.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Martin Grigorov-4
That's why I put "MyPage.java:" above it.
I've never tried to make the page invisible :-)

On Wed, Aug 10, 2011 at 8:32 PM, Igor Vaynberg <[hidden email]> wrote:

> this will get called more than once for a component that starts out
> and remains invisible for a while.
>
> -igor
>
>
> On Wed, Aug 10, 2011 at 10:25 AM, Martin Grigorov <[hidden email]> wrote:
>> MyPage.java:
>> protected void onBeforeRender() {
>>
>>        if (!hasBeenRendered()) {
>>            send(...);
>>        }
>>
>>        super.onBeforeRender();
>>    }
>>
>> On Wed, Aug 10, 2011 at 8:18 PM, armandoxxx <[hidden email]> wrote:
>>> @pedro I know. That's why I didn't put the event call in onInitialize()
>>> method ;)
>>>
>>> @martin: I if use on before render .. my event would be triggered everytime
>>> my component renders .. so if I want 1 time event after the component is
>>> initialized I have to use somekind of a flag for this event to be called
>>> just once. So that's why I suggested afterInitialized() method ;)
>>>
>>> thank you guys for responses
>>>
>>> Regards
>>>
>>> Armando
>>>
>>> --
>>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3733649.html
>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Igor Vaynberg-2
what if a component is added later during a panel swap?

-igor

On Wed, Aug 10, 2011 at 10:34 AM, Martin Grigorov <[hidden email]> wrote:

> That's why I put "MyPage.java:" above it.
> I've never tried to make the page invisible :-)
>
> On Wed, Aug 10, 2011 at 8:32 PM, Igor Vaynberg <[hidden email]> wrote:
>> this will get called more than once for a component that starts out
>> and remains invisible for a while.
>>
>> -igor
>>
>>
>> On Wed, Aug 10, 2011 at 10:25 AM, Martin Grigorov <[hidden email]> wrote:
>>> MyPage.java:
>>> protected void onBeforeRender() {
>>>
>>>        if (!hasBeenRendered()) {
>>>            send(...);
>>>        }
>>>
>>>        super.onBeforeRender();
>>>    }
>>>
>>> On Wed, Aug 10, 2011 at 8:18 PM, armandoxxx <[hidden email]> wrote:
>>>> @pedro I know. That's why I didn't put the event call in onInitialize()
>>>> method ;)
>>>>
>>>> @martin: I if use on before render .. my event would be triggered everytime
>>>> my component renders .. so if I want 1 time event after the component is
>>>> initialized I have to use somekind of a flag for this event to be called
>>>> just once. So that's why I suggested afterInitialized() method ;)
>>>>
>>>> thank you guys for responses
>>>>
>>>> Regards
>>>>
>>>> Armando
>>>>
>>>> --
>>>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3733649.html
>>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Martin Grigorov
>>> jWeekend
>>> Training, Consulting, Development
>>> http://jWeekend.com
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Martin Grigorov-4
Now I'm convinced we need onAfterInitialize() :-)

On Wed, Aug 10, 2011 at 8:42 PM, Igor Vaynberg <[hidden email]> wrote:

> what if a component is added later during a panel swap?
>
> -igor
>
> On Wed, Aug 10, 2011 at 10:34 AM, Martin Grigorov <[hidden email]> wrote:
>> That's why I put "MyPage.java:" above it.
>> I've never tried to make the page invisible :-)
>>
>> On Wed, Aug 10, 2011 at 8:32 PM, Igor Vaynberg <[hidden email]> wrote:
>>> this will get called more than once for a component that starts out
>>> and remains invisible for a while.
>>>
>>> -igor
>>>
>>>
>>> On Wed, Aug 10, 2011 at 10:25 AM, Martin Grigorov <[hidden email]> wrote:
>>>> MyPage.java:
>>>> protected void onBeforeRender() {
>>>>
>>>>        if (!hasBeenRendered()) {
>>>>            send(...);
>>>>        }
>>>>
>>>>        super.onBeforeRender();
>>>>    }
>>>>
>>>> On Wed, Aug 10, 2011 at 8:18 PM, armandoxxx <[hidden email]> wrote:
>>>>> @pedro I know. That's why I didn't put the event call in onInitialize()
>>>>> method ;)
>>>>>
>>>>> @martin: I if use on before render .. my event would be triggered everytime
>>>>> my component renders .. so if I want 1 time event after the component is
>>>>> initialized I have to use somekind of a flag for this event to be called
>>>>> just once. So that's why I suggested afterInitialized() method ;)
>>>>>
>>>>> thank you guys for responses
>>>>>
>>>>> Regards
>>>>>
>>>>> Armando
>>>>>
>>>>> --
>>>>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3733649.html
>>>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Martin Grigorov
>>>> jWeekend
>>>> Training, Consulting, Development
>>>> http://jWeekend.com
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

armandoxxx
Igor: thank you for your reply and your solution. Could you please discuss this case with other developers and let me know what they think? In my opinion framework should make my job easier not force me to do workarounds to get what I need. Just a thought.

Martin: thank you :D

Kind regards

Armando
Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Igor Vaynberg-2
On Thu, Aug 11, 2011 at 4:35 AM, armandoxxx <[hidden email]> wrote:
> Igor: thank you for your reply and your solution. Could you please discuss
> this case with other developers and let me know what they think?

this is the place where the developers discuss things. if any of them
want to chime in they are free to do so. this list is our main means
of communication.

> In my
> opinion framework should make my job easier not force me to do workarounds
> to get what I need. Just a thought.

nothing i have shown you is a workaround, it is using extension points
offered by the framework to layer in new functionality specific to
your usecase.

-igor


>
> Martin: thank you :D
>
> Kind regards
>
> Armando
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3735601.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Bruno Borges
Isn't this correct?

onInitialize() {
  super.onInitialize();
  ... // whatever I put here would be the same as overriding
onAfterInitialize();
}

*Bruno Borges*
www.brunoborges.com.br
+55 21 76727099



On Thu, Aug 11, 2011 at 12:35 PM, Igor Vaynberg <[hidden email]>wrote:

> On Thu, Aug 11, 2011 at 4:35 AM, armandoxxx <[hidden email]>
> wrote:
> > Igor: thank you for your reply and your solution. Could you please
> discuss
> > this case with other developers and let me know what they think?
>
> this is the place where the developers discuss things. if any of them
> want to chime in they are free to do so. this list is our main means
> of communication.
>
> > In my
> > opinion framework should make my job easier not force me to do
> workarounds
> > to get what I need. Just a thought.
>
> nothing i have shown you is a workaround, it is using extension points
> offered by the framework to layer in new functionality specific to
> your usecase.
>
> -igor
>
>
> >
> > Martin: thank you :D
> >
> > Kind regards
> >
> > Armando
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3735601.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

armandoxxx
This post was updated on .
In reply to this post by Igor Vaynberg-2
@IGor: I figured it out .. no need for new features.

@Bruno: if you write onAfterInitialize() in onInitialize() you can't be sure all components on the page we're
 initialized()


Regards

Armando
Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

Bruno Borges
Yes, now I understood. :-) Thanks

*Bruno Borges*
www.brunoborges.com.br
+55 21 76727099



On Fri, Aug 12, 2011 at 2:56 AM, armandoxxx <[hidden email]>wrote:

> @IGor: I figured it out .. no need for new features.
>
> @Bruno: if you cann onAfterInitialize() in onInitialize() you can't be sure
> all components on the page we're
>  initialized()
>
>
> Regards
>
> Armando
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3738002.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: Question (or feature request) afterOnInitialize()

armandoxxx
This post was updated on .
my fix was


public class BasePage extends WebPage {

	private boolean afterInitEventsSend	= false;
	private final List afterInitEventList = new ArrayList();

	@Override
	protected void onConfigure() {
		super.onConfigure();
		if (!this.afterInitEventsSend) {
			this.sendAfterInitEvents();
		}
	}
	
	private void sendAfterInitEvents() {
		if (!this.afterInitEventList.isEmpty()) {
			//iterate the list .. send the events
		}
	}
}


if someone needs it ..

Regards

Armando