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 > 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