Re: Behaviour.onInitialise()

2013-02-07 Thread Martin Grigorov
Hi,

I'm not sure whether there is a specific reason why this method is not in
the API.
Maybe just because no one needed/noticed it.
Maybe there is something wrong in it which I don't see at the moment.
Anyway create a ticket for improvement.

Yet another way is to use IComponentInializationListener that assigns the
behavior when the component is being initialized.


On Thu, Feb 7, 2013 at 5:14 AM, Colin Rogers 
colin.rog...@objectconsulting.com.au wrote:

 Martin and other Wicketeers,

 I have a quick, small question; why is there no 'onInitiailise()' method
 on Behaviour classes?

 There is an 'bind' method, but this, unlike 'onInitialise' is call
 immediately on binding to component, whether the component is in the
 component tree or not. Obviously it's very easy to work around;

 * Simply ensure that bind is called after the component is added
 to the component tree, even throwing an exception when 'component'
 parameter has null for a parent. (This is how AbstractAjaxBehavior works).

 * Add a 'firstTime' flag in onConfigure, and set to false after
 the onInitialise functionality is performed.

 While it is easy to work around, it seems odd that Behaviours lack the
 common onInitialise that all Wicket components otherwise have, I'm curious
 as to why that is, and hoping it wouldn't be an issue to add - it would aid
 in removing boiler plate code in Behaviours.

 Cheers,
 Col.

 PS. Apologies for spelling 'initialise' and 'behaviour' correctly - I
 can't help it... :)

 EMAIL DISCLAIMER This email message and its attachments are confidential
 and may also contain copyright or privileged material. If you are not the
 intended recipient, you may not forward the email or disclose or use the
 information contained in it. If you have received this email message in
 error, please advise the sender immediately by replying to this email and
 delete the message and any associated attachments. Any views, opinions,
 conclusions, advice or statements expressed in this email message are those
 of the individual sender and should not be relied upon as the considered
 view, opinion, conclusions, advice or statement of this company except
 where the sender expressly, and with authority, states them to be the
 considered view, opinion, conclusions, advice or statement of this company.
 Every care is taken but we recommend that you scan any attachments for
 viruses.




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


Re: Behaviour.onInitialise()

2013-02-07 Thread Igor Vaynberg
What happens if the behavior is added after the component has already been
initialized? Does its oninitialize() still get called? Ambiguities like
this is the reason why there is no such method.

-igor

On Wednesday, February 6, 2013, Colin Rogers wrote:

 Martin and other Wicketeers,

 I have a quick, small question; why is there no 'onInitiailise()' method
 on Behaviour classes?

 There is an 'bind' method, but this, unlike 'onInitialise' is call
 immediately on binding to component, whether the component is in the
 component tree or not. Obviously it's very easy to work around;

 * Simply ensure that bind is called after the component is added
 to the component tree, even throwing an exception when 'component'
 parameter has null for a parent. (This is how AbstractAjaxBehavior works).

 * Add a 'firstTime' flag in onConfigure, and set to false after
 the onInitialise functionality is performed.

 While it is easy to work around, it seems odd that Behaviours lack the
 common onInitialise that all Wicket components otherwise have, I'm curious
 as to why that is, and hoping it wouldn't be an issue to add - it would aid
 in removing boiler plate code in Behaviours.

 Cheers,
 Col.

 PS. Apologies for spelling 'initialise' and 'behaviour' correctly - I
 can't help it... :)

 EMAIL DISCLAIMER This email message and its attachments are confidential
 and may also contain copyright or privileged material. If you are not the
 intended recipient, you may not forward the email or disclose or use the
 information contained in it. If you have received this email message in
 error, please advise the sender immediately by replying to this email and
 delete the message and any associated attachments. Any views, opinions,
 conclusions, advice or statements expressed in this email message are those
 of the individual sender and should not be relied upon as the considered
 view, opinion, conclusions, advice or statement of this company except
 where the sender expressly, and with authority, states them to be the
 considered view, opinion, conclusions, advice or statement of this company.
 Every care is taken but we recommend that you scan any attachments for
 viruses.



RE: Behaviour.onInitialise()

2013-02-07 Thread Colin Rogers
That ambiguous-ness is ever more present when you use bind - as there is no 
guarantee what state the component is in (hence our need for boilerplate code, 
to determine that state). It's not there if  you are using onInitialise, as 
it's part of the component lifecycle, you know what state the parent component 
is in.

What happens if the behaviour is added after the component has already been 
initialized? Does its oninitialize() still get called?

Of course - I'd expect adding a Behaviour to a Panel is no different from add a 
Label to a Panel. The onInitialise in the Behaviour would be called the same as 
the Label - as and when it's part of the component tree. As behaviours are 
re-useable extensions to components, I'd expect them to behave in the same way.

Cheers,
Col.

-Original Message-
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com]
Sent: 07 February 2013 19:14
To: users@wicket.apache.org
Subject: Re: Behaviour.onInitialise()

What happens if the behavior is added after the component has already been 
initialized? Does its oninitialize() still get called? Ambiguities like this is 
the reason why there is no such method.

-igor

On Wednesday, February 6, 2013, Colin Rogers wrote:

 Martin and other Wicketeers,

 I have a quick, small question; why is there no 'onInitiailise()'
 method on Behaviour classes?

 There is an 'bind' method, but this, unlike 'onInitialise' is call
 immediately on binding to component, whether the component is in the
 component tree or not. Obviously it's very easy to work around;

 * Simply ensure that bind is called after the component is added
 to the component tree, even throwing an exception when 'component'
 parameter has null for a parent. (This is how AbstractAjaxBehavior works).

 * Add a 'firstTime' flag in onConfigure, and set to false after
 the onInitialise functionality is performed.

 While it is easy to work around, it seems odd that Behaviours lack the
 common onInitialise that all Wicket components otherwise have, I'm
 curious as to why that is, and hoping it wouldn't be an issue to add -
 it would aid in removing boiler plate code in Behaviours.

 Cheers,
 Col.

 PS. Apologies for spelling 'initialise' and 'behaviour' correctly - I
 can't help it... :)

 EMAIL DISCLAIMER This email message and its attachments are
 confidential and may also contain copyright or privileged material. If
 you are not the intended recipient, you may not forward the email or
 disclose or use the information contained in it. If you have received
 this email message in error, please advise the sender immediately by
 replying to this email and delete the message and any associated
 attachments. Any views, opinions, conclusions, advice or statements
 expressed in this email message are those of the individual sender and
 should not be relied upon as the considered view, opinion,
 conclusions, advice or statement of this company except where the
 sender expressly, and with authority, states them to be the considered view, 
 opinion, conclusions, advice or statement of this company.
 Every care is taken but we recommend that you scan any attachments for
 viruses.

EMAIL DISCLAIMER This email message and its attachments are confidential and 
may also contain copyright or privileged material. If you are not the intended 
recipient, you may not forward the email or disclose or use the information 
contained in it. If you have received this email message in error, please 
advise the sender immediately by replying to this email and delete the message 
and any associated attachments. Any views, opinions, conclusions, advice or 
statements expressed in this email message are those of the individual sender 
and should not be relied upon as the considered view, opinion, conclusions, 
advice or statement of this company except where the sender expressly, and with 
authority, states them to be the considered view, opinion, conclusions, advice 
or statement of this company. Every care is taken but we recommend that you 
scan any attachments for viruses.

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



Re: Behaviour.onInitialise()

2013-02-07 Thread Igor Vaynberg
On Thu, Feb 7, 2013 at 3:33 PM, Colin Rogers
colin.rog...@objectconsulting.com.au wrote:
 That ambiguous-ness is ever more present when you use bind - as there is no 
 guarantee what state the component is in (hence our need for boilerplate 
 code, to determine that state). It's not there if  you are using 
 onInitialise, as it's part of the component lifecycle, you know what state 
 the parent component is in.

thats why bind() makes no guarantee about the state of the component,
it is simply called when the behavior is added to the component.

 What happens if the behaviour is added after the component has already been 
 initialized? Does its oninitialize() still get called?

 Of course - I'd expect adding a Behaviour to a Panel is no different from add 
 a Label to a Panel. The onInitialise in the Behaviour would be called the 
 same as the Label - as and when it's part of the component tree. As 
 behaviours are re-useable extensions to components, I'd expect them to behave 
 in the same way.

there is a small problem with this line of thinking: behaviors are
different from components in that one instance of a behavior can be
added to multiple components. so behavior A gets added to a component
that is already initialized - no onInitialize call, then same instance
gets added to component B that is not yet initialized, now
onInitialize is called? doesnt make any sense unfortunately.

perhaps what you can do is describe your concrete usecase for needing
this method and we may be able to better help  you.

-igor


 Cheers,
 Col.

 -Original Message-
 From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com]
 Sent: 07 February 2013 19:14
 To: users@wicket.apache.org
 Subject: Re: Behaviour.onInitialise()

 What happens if the behavior is added after the component has already been 
 initialized? Does its oninitialize() still get called? Ambiguities like this 
 is the reason why there is no such method.

 -igor

 On Wednesday, February 6, 2013, Colin Rogers wrote:

 Martin and other Wicketeers,

 I have a quick, small question; why is there no 'onInitiailise()'
 method on Behaviour classes?

 There is an 'bind' method, but this, unlike 'onInitialise' is call
 immediately on binding to component, whether the component is in the
 component tree or not. Obviously it's very easy to work around;

 * Simply ensure that bind is called after the component is added
 to the component tree, even throwing an exception when 'component'
 parameter has null for a parent. (This is how AbstractAjaxBehavior works).

 * Add a 'firstTime' flag in onConfigure, and set to false after
 the onInitialise functionality is performed.

 While it is easy to work around, it seems odd that Behaviours lack the
 common onInitialise that all Wicket components otherwise have, I'm
 curious as to why that is, and hoping it wouldn't be an issue to add -
 it would aid in removing boiler plate code in Behaviours.

 Cheers,
 Col.

 PS. Apologies for spelling 'initialise' and 'behaviour' correctly - I
 can't help it... :)

 EMAIL DISCLAIMER This email message and its attachments are
 confidential and may also contain copyright or privileged material. If
 you are not the intended recipient, you may not forward the email or
 disclose or use the information contained in it. If you have received
 this email message in error, please advise the sender immediately by
 replying to this email and delete the message and any associated
 attachments. Any views, opinions, conclusions, advice or statements
 expressed in this email message are those of the individual sender and
 should not be relied upon as the considered view, opinion,
 conclusions, advice or statement of this company except where the
 sender expressly, and with authority, states them to be the considered view, 
 opinion, conclusions, advice or statement of this company.
 Every care is taken but we recommend that you scan any attachments for
 viruses.

 EMAIL DISCLAIMER This email message and its attachments are confidential and 
 may also contain copyright or privileged material. If you are not the 
 intended recipient, you may not forward the email or disclose or use the 
 information contained in it. If you have received this email message in 
 error, please advise the sender immediately by replying to this email and 
 delete the message and any associated attachments. Any views, opinions, 
 conclusions, advice or statements expressed in this email message are those 
 of the individual sender and should not be relied upon as the considered 
 view, opinion, conclusions, advice or statement of this company except where 
 the sender expressly, and with authority, states them to be the considered 
 view, opinion, conclusions, advice or statement of this company. Every care 
 is taken but we recommend that you scan any attachments for viruses.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org

RE: Behaviour.onInitialise()

2013-02-07 Thread Colin Rogers
That actually makes sense, now. I didn't realise that Behaviours could be added 
to different components  - I incorrectly assumed they couldn't.

It also makes clear why bind has the component as a parameter, as it would be 
called multiple times for difference components.

Thanks for the answer! :)

Cheers,
Col.

-Original Message-
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com]
Sent: 08 February 2013 10:59
To: users@wicket.apache.org
Subject: Re: Behaviour.onInitialise()

On Thu, Feb 7, 2013 at 3:33 PM, Colin Rogers 
colin.rog...@objectconsulting.com.au wrote:
 That ambiguous-ness is ever more present when you use bind - as there is no 
 guarantee what state the component is in (hence our need for boilerplate 
 code, to determine that state). It's not there if  you are using 
 onInitialise, as it's part of the component lifecycle, you know what state 
 the parent component is in.

thats why bind() makes no guarantee about the state of the component, it is 
simply called when the behavior is added to the component.

 What happens if the behaviour is added after the component has already been 
 initialized? Does its oninitialize() still get called?

 Of course - I'd expect adding a Behaviour to a Panel is no different from add 
 a Label to a Panel. The onInitialise in the Behaviour would be called the 
 same as the Label - as and when it's part of the component tree. As 
 behaviours are re-useable extensions to components, I'd expect them to behave 
 in the same way.

there is a small problem with this line of thinking: behaviors are different 
from components in that one instance of a behavior can be added to multiple 
components. so behavior A gets added to a component that is already initialized 
- no onInitialize call, then same instance gets added to component B that is 
not yet initialized, now onInitialize is called? doesnt make any sense 
unfortunately.

perhaps what you can do is describe your concrete usecase for needing this 
method and we may be able to better help  you.

-igor


 Cheers,
 Col.

 -Original Message-
 From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com]
 Sent: 07 February 2013 19:14
 To: users@wicket.apache.org
 Subject: Re: Behaviour.onInitialise()

 What happens if the behavior is added after the component has already been 
 initialized? Does its oninitialize() still get called? Ambiguities like this 
 is the reason why there is no such method.

 -igor

 On Wednesday, February 6, 2013, Colin Rogers wrote:

 Martin and other Wicketeers,

 I have a quick, small question; why is there no 'onInitiailise()'
 method on Behaviour classes?

 There is an 'bind' method, but this, unlike 'onInitialise' is call
 immediately on binding to component, whether the component is in the
 component tree or not. Obviously it's very easy to work around;

 * Simply ensure that bind is called after the component is added
 to the component tree, even throwing an exception when 'component'
 parameter has null for a parent. (This is how AbstractAjaxBehavior works).

 * Add a 'firstTime' flag in onConfigure, and set to false after
 the onInitialise functionality is performed.

 While it is easy to work around, it seems odd that Behaviours lack
 the common onInitialise that all Wicket components otherwise have,
 I'm curious as to why that is, and hoping it wouldn't be an issue to
 add - it would aid in removing boiler plate code in Behaviours.

 Cheers,
 Col.

 PS. Apologies for spelling 'initialise' and 'behaviour' correctly - I
 can't help it... :)

 EMAIL DISCLAIMER This email message and its attachments are
 confidential and may also contain copyright or privileged material.
 If you are not the intended recipient, you may not forward the email
 or disclose or use the information contained in it. If you have
 received this email message in error, please advise the sender
 immediately by replying to this email and delete the message and any
 associated attachments. Any views, opinions, conclusions, advice or
 statements expressed in this email message are those of the
 individual sender and should not be relied upon as the considered
 view, opinion, conclusions, advice or statement of this company
 except where the sender expressly, and with authority, states them to be the 
 considered view, opinion, conclusions, advice or statement of this company.
 Every care is taken but we recommend that you scan any attachments
 for viruses.

 EMAIL DISCLAIMER This email message and its attachments are confidential and 
 may also contain copyright or privileged material. If you are not the 
 intended recipient, you may not forward the email or disclose or use the 
 information contained in it. If you have received this email message in 
 error, please advise the sender immediately by replying to this email and 
 delete the message and any associated attachments. Any views, opinions, 
 conclusions, advice or statements expressed in this email message are those