Re: Component creation and initialization
El dom, 17-05-2009 a las 15:17 -0700, Igor Vaynberg escribió: IOC works fine if you use constructor injection :) which is what you should use. +1 Tor Iver, take a look at http://misko.hevery.com/code-reviewers-guide/ It is a very good reading! the only reason people may prefer setter injection is that configuration looks nicer. param name=service ref=some.service/ looks a lot nicer then constructor-arg index=2 ref=some.service/ -igor On Sun, May 17, 2009 at 2:50 PM, Wilhelmsen Tor Iver toriv...@arrive.no wrote: 2 - A constructor is for constructing - your object should not be in an incomplete state when the constructor is finished (such a state that methods such as isVisible can not be called) Tha language ensures that the object is complete when the constructor exits, but with the exception of immutalbe objects, as a component it is not complete. People are e.g. adding to lists at runtime, leading to possible subcomponent initialiation later on in the relevant method of a Loop or ListView for instance. It could also be argued for instance that a LoadableDetachableModel is /intentionally/ incomplete when the constructor exits. Overriding methods like isVisible() is also a form of hack to postpone a property value to a later time (basically the component stops having a real property called visible since the setter modifies a variable that the getter does not care about). The desire to have completeness after constructor completion also runs afoul with modern ideas like IoC where it is left to an outside agent to complete configuration of a component. However, I agree that the attention of the thread originator should be on the models. - Tor Iver - 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: SV: Component creation and initialization
From my perspective the isVisible() case deserves generification. I know that there is a task for Wicket 1.5. I mean after that we should write an article in Wiki. Wilhelmsen Tor Iver wrote: Overriding methods like isVisible() is also a form of hack to postpone a property value to a later time (basically the component stops having a real property called visible since the setter modifies a variable that the getter does not care about). -- View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23592389.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: Component creation and initialization
On Sun, May 17, 2009 at 6:17 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote: IOC works fine if you use constructor injection :) which is what you should use. the only reason people may prefer setter injection is that configuration looks nicer. And, when circular dependencies won't allow you to use constructor-based injection (only an issue with class-based proxies). - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
If the question is ressurecting again and again then it is an evidence that there is something to address and improve. At least Wicket does not have a method with self-documented name which deffers component creation. As the result people have to search (using different words) and they don't satisfy with the result 'cause the topic is still looks open. This list is quite active and I appreciate the answers of core developers. Probably Wicket is so good because in addition to the devotion of talented and capable people to implementation, they do hear what the users say directly, not indirectly via support team. Jeremy Thomerson-5 wrote: I actually had to Google that one. But, yes, that is the general consensus that I've seen. If you wanted to write a page that showed the different ways that you mentioned, that would be fine. It really just depends on if you really need lazy component creation, and then how you want to implement it. -- Jeremy Thomerson http://www.wickettraining.com On Fri, May 15, 2009 at 11:13 AM, Clint Popetz cl...@42lines.net wrote: TMTOWTDI - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23582495.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
SV: Component creation and initialization
2 - A constructor is for constructing - your object should not be in an incomplete state when the constructor is finished (such a state that methods such as isVisible can not be called) Tha language ensures that the object is complete when the constructor exits, but with the exception of immutalbe objects, as a component it is not complete. People are e.g. adding to lists at runtime, leading to possible subcomponent initialiation later on in the relevant method of a Loop or ListView for instance. It could also be argued for instance that a LoadableDetachableModel is /intentionally/ incomplete when the constructor exits. Overriding methods like isVisible() is also a form of hack to postpone a property value to a later time (basically the component stops having a real property called visible since the setter modifies a variable that the getter does not care about). The desire to have completeness after constructor completion also runs afoul with modern ideas like IoC where it is left to an outside agent to complete configuration of a component. However, I agree that the attention of the thread originator should be on the models. - Tor Iver - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
IOC works fine if you use constructor injection :) which is what you should use. the only reason people may prefer setter injection is that configuration looks nicer. param name=service ref=some.service/ looks a lot nicer then constructor-arg index=2 ref=some.service/ -igor On Sun, May 17, 2009 at 2:50 PM, Wilhelmsen Tor Iver toriv...@arrive.no wrote: 2 - A constructor is for constructing - your object should not be in an incomplete state when the constructor is finished (such a state that methods such as isVisible can not be called) Tha language ensures that the object is complete when the constructor exits, but with the exception of immutalbe objects, as a component it is not complete. People are e.g. adding to lists at runtime, leading to possible subcomponent initialiation later on in the relevant method of a Loop or ListView for instance. It could also be argued for instance that a LoadableDetachableModel is /intentionally/ incomplete when the constructor exits. Overriding methods like isVisible() is also a form of hack to postpone a property value to a later time (basically the component stops having a real property called visible since the setter modifies a variable that the getter does not care about). The desire to have completeness after constructor completion also runs afoul with modern ideas like IoC where it is left to an outside agent to complete configuration of a component. However, I agree that the attention of the thread originator should be on the models. - Tor Iver - 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: Component creation and initialization
a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.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 - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553847.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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
by your own argument your own code will have to call your second-chance init constructor before invoking *any* method on the component. so instead of boolean visible=getMyComponent().isvisible(); you will have to now do Component c=getMyComponent(); if (!c.isinitted()) {c.initI(); } boolean visible=c.isvisible(); that init line is now necessary because you *never* know if a component has been initialized, so every access to any component memeber has to be prefixed by that init check. that will be fun! or we can just use constructors since thats what they are designed to do (its in the name) -igor On Thu, May 14, 2009 at 10:21 PM, Vladimir K koval...@gmail.com wrote: it has just come to my mind I'm afraid Wicket can't guarantee that onBeforeRender would be called in any case. So there could be a case (isVisible() for instance) when onBeforeRender is not called yet but overriding method could read yet-not-completely-initialized object state. Instead of thinking how to work around isVisible() and the other cases why not just add a second-chance method and invoke it in appropriate places. in Component: boolean complete = false; void ensureCompletelyInitialized() { if(!complete){ finalizeCreation(); complete = true; } } void internalBeforeRender() { ensureCompletelyInitialized(); ... } I believe it makes sence. Martijn Dashorst wrote: This has been discussed till death previously and we have excluded it from our roadmap. We will never have an init() method for components. Gossling gave us a Constructor to initialize your Objects. Search and read the archives if you want more information on the subject. Martijn On Fri, May 15, 2009 at 12:36 AM, Juan G. Arias juangar...@gmail.com wrote: It would be very nice to add a new phase for component creation, like I said, an init() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553618.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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.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 - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553847.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 - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23554210.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: Component creation and initialization
Igor, I didn't mean spreading this approach everywhere :) My intention was to draw your attention on that onBeforeRender probably is a good place to delay construction but should be used with extra care and some sort of simplification (more appropriate method) would be great. You turned it insideout and it does not make sence anymore :) Igor, Jeremy, thanks a lot for your suggestions. I have some food for my brain to think about. igor.vaynberg wrote: by your own argument your own code will have to call your second-chance init constructor before invoking *any* method on the component. so instead of boolean visible=getMyComponent().isvisible(); you will have to now do Component c=getMyComponent(); if (!c.isinitted()) {c.initI(); } boolean visible=c.isvisible(); that init line is now necessary because you *never* know if a component has been initialized, so every access to any component memeber has to be prefixed by that init check. that will be fun! or we can just use constructors since thats what they are designed to do (its in the name) -igor On Thu, May 14, 2009 at 10:21 PM, Vladimir K koval...@gmail.com wrote: it has just come to my mind I'm afraid Wicket can't guarantee that onBeforeRender would be called in any case. So there could be a case (isVisible() for instance) when onBeforeRender is not called yet but overriding method could read yet-not-completely-initialized object state. Instead of thinking how to work around isVisible() and the other cases why not just add a second-chance method and invoke it in appropriate places. in Component: boolean complete = false; void ensureCompletelyInitialized() { if(!complete){ finalizeCreation(); complete = true; } } void internalBeforeRender() { ensureCompletelyInitialized(); ... } I believe it makes sence. Martijn Dashorst wrote: This has been discussed till death previously and we have excluded it from our roadmap. We will never have an init() method for components. Gossling gave us a Constructor to initialize your Objects. Search and read the archives if you want more information on the subject. Martijn On Fri, May 15, 2009 at 12:36 AM, Juan G. Arias juangar...@gmail.com wrote: It would be very nice to add a new phase for component creation, like I said, an init() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553618.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 - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23554417.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: Component creation and initialization
The horse is pretty alive - https://issues.apache.org/jira/browse/WICKET-1134. Jeremy Thomerson-5 wrote: With regards to multiple wicket:extend tags - that is also an old, dead horse that doesn't need to be beat right now. The user list has a lot of discussion on it. The simplest way to allow a child to contribute multiple components to a page is the same as you would do in normal java (which does not allow multiple inheritance) - expose multiple overridable methods that provide the components... i.e.: -- View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23557008.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: Component creation and initialization
. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Clint Popetz http://42lines.net Scalable Web Application Development - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Clint Popetz http://42lines.net Scalable Web Application Development - 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: Component creation and initialization
On Fri, May 15, 2009 at 10:24 AM, Jeremy Thomerson jer...@wickettraining.com wrote: Interestingly, in the long-standing defacto article on asking smart questions, the very first thing it says to do is to search the forums [1]. FWIW, I did search the list, before posting. I found a lot of disagreement about this topic, no resolution, and mostly threads that just trailed off. I was hoping that perhaps there was a consensus pointing to a best practice with respect to creating component hierarchies in wicket that works around the problem of constructors in java, but that does not seem to be the case. Some people advocate onBeforeRender with checks to make sure it's the first time, some people advocated adding an onBeforeFirstRender() to the framework, which never made it in. Some use init() methods like I posted, and some use factory patterns. If the consensus is just that TMTOWTDI, that's fine too I suppose, but it will result in this thread resurfacing bi-monthly. If I were to write up a wiki document right now on this topic, it would reflect my own confusion on this topic, so I'll wait until lucidity arrives. -Clint - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
I actually had to Google that one. But, yes, that is the general consensus that I've seen. If you wanted to write a page that showed the different ways that you mentioned, that would be fine. It really just depends on if you really need lazy component creation, and then how you want to implement it. -- Jeremy Thomerson http://www.wickettraining.com On Fri, May 15, 2009 at 11:13 AM, Clint Popetz cl...@42lines.net wrote: TMTOWTDI - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Component creation and initialization
Hi all, Is there a way in wicket for separate the object's instantiation phase from the inner component's creation phase? Just like the init() method in application, but for my components. Another way to see it, just in case it's not clear: Is there an already defined contract for component creation, that allows me to create the components I will use in some panel/page, but not to do it in the Java constructor? Thanks in advance! Juan
Re: Component creation and initialization
You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com On Thu, May 14, 2009 at 12:51 PM, Juan G. Arias juangar...@gmail.com wrote: Hi all, Is there a way in wicket for separate the object's instantiation phase from the inner component's creation phase? Just like the init() method in application, but for my components. Another way to see it, just in case it's not clear: Is there an already defined contract for component creation, that allows me to create the components I will use in some panel/page, but not to do it in the Java constructor? Thanks in advance! Juan - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
It would be very nice to add a new phase for component creation, like I said, an init() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
This has been discussed till death previously and we have excluded it from our roadmap. We will never have an init() method for components. Gossling gave us a Constructor to initialize your Objects. Search and read the archives if you want more information on the subject. Martijn On Fri, May 15, 2009 at 12:36 AM, Juan G. Arias juangar...@gmail.com wrote: It would be very nice to add a new phase for component creation, like I said, an init() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
Martijn, here Java is not safe as a language. Yo're able to invoke overrided methods on non-completely constructed objects. from my perspective it is a regular case in Wicket: class SampleComponent extends ... { String parameter; SampleComponent(String id, String parameter) { super(id); this.parameter = parameter; } // method is called from within superconstructor @Override void createAdditionalComponents(RepeatingView rv) { useSomehow(parameter); } } I know two approaches to work around: - onBeforeRender - a closure as a constructor formal parameter. But the latter does not help with built-in components. If Wicket does not help us with adding appropriate method for second-step-initialization it should document it in wiki, javadoc and books dear user, when overriding methods, beware using of yet unassigned constructor parameters. Hmm ... sounds stupid :) Martijn Dashorst wrote: This has been discussed till death previously and we have excluded it from our roadmap. We will never have an init() method for components. Gossling gave us a Constructor to initialize your Objects. Search and read the archives if you want more information on the subject. Martijn On Fri, May 15, 2009 at 12:36 AM, Juan G. Arias juangar...@gmail.com wrote: It would be very nice to add a new phase for component creation, like I said, an init() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.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: Component creation and initialization
Do you have any examples of where Wicket calls an overridable method from the constructor of a Wicket class? If so, please file it as a JIRA - that would be a bug. Most java programmers know not to call overridable methods from the constructor as a general rule, although there are times when it could inadvertantly happen - which is why we need bug reports if you see that happening. -- Jeremy Thomerson http://www.wickettraining.com On Fri, May 15, 2009 at 12:01 AM, Vladimir K koval...@gmail.com wrote: Martijn, here Java is not safe as a language. Yo're able to invoke overrided methods on non-completely constructed objects. from my perspective it is a regular case in Wicket: class SampleComponent extends ... { String parameter; SampleComponent(String id, String parameter) { super(id); this.parameter = parameter; } // method is called from within superconstructor �...@override void createAdditionalComponents(RepeatingView rv) { useSomehow(parameter); } } I know two approaches to work around: - onBeforeRender - a closure as a constructor formal parameter. But the latter does not help with built-in components. If Wicket does not help us with adding appropriate method for second-step-initialization it should document it in wiki, javadoc and books dear user, when overriding methods, beware using of yet unassigned constructor parameters. Hmm ... sounds stupid :) Martijn Dashorst wrote: This has been discussed till death previously and we have excluded it from our roadmap. We will never have an init() method for components. Gossling gave us a Constructor to initialize your Objects. Search and read the archives if you want more information on the subject. Martijn On Fri, May 15, 2009 at 12:36 AM, Juan G. Arias juangar...@gmail.com wrote: It would be very nice to add a new phase for component creation, like I said, an init() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
it has just come to my mind I'm afraid Wicket can't guarantee that onBeforeRender would be called in any case. So there could be a case (isVisible() for instance) when onBeforeRender is not called yet but overriding method could read yet-not-completely-initialized object state. Instead of thinking how to work around isVisible() and the other cases why not just add a second-chance method and invoke it in appropriate places. in Component: boolean complete = false; void ensureCompletelyInitialized() { if(!complete){ finalizeCreation(); complete = true; } } void internalBeforeRender() { ensureCompletelyInitialized(); ... } I believe it makes sence. Martijn Dashorst wrote: This has been discussed till death previously and we have excluded it from our roadmap. We will never have an init() method for components. Gossling gave us a Constructor to initialize your Objects. Search and read the archives if you want more information on the subject. Martijn On Fri, May 15, 2009 at 12:36 AM, Juan G. Arias juangar...@gmail.com wrote: It would be very nice to add a new phase for component creation, like I said, an init() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553618.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: Component creation and initialization
1 - isVisible isn't called in the constructor. 2 - A constructor is for constructing - your object should not be in an incomplete state when the constructor is finished (such a state that methods such as isVisible can not be called) 3 - the question was about delayed creation of child components - why would isVisible rely on child components being created or not? by the time isVisible is called, any instance or model data that you need to compute visibility should have been initialized so that the component can work. In my experience, typically these needs for delayed component creation come not from a true need, but from a lack of understanding of the proper use of models. -- Jeremy Thomerson http://www.wickettraining.com On Fri, May 15, 2009 at 12:21 AM, Vladimir K koval...@gmail.com wrote: it has just come to my mind I'm afraid Wicket can't guarantee that onBeforeRender would be called in any case. So there could be a case (isVisible() for instance) when onBeforeRender is not called yet but overriding method could read yet-not-completely-initialized object state. Instead of thinking how to work around isVisible() and the other cases why not just add a second-chance method and invoke it in appropriate places. in Component: boolean complete = false; void ensureCompletelyInitialized() { if(!complete){ finalizeCreation(); complete = true; } } void internalBeforeRender() { ensureCompletelyInitialized(); ... } I believe it makes sence. Martijn Dashorst wrote: This has been discussed till death previously and we have excluded it from our roadmap. We will never have an init() method for components. Gossling gave us a Constructor to initialize your Objects. Search and read the archives if you want more information on the subject. Martijn On Fri, May 15, 2009 at 12:36 AM, Juan G. Arias juangar...@gmail.com wrote: It would be very nice to add a new phase for component creation, like I said, an init() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553618.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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component creation and initialization
Jeremy, I can't add another example to mentioned RepeatingView. Concerning RepeatingView... Wicket allow me just one point to subclass parent component markup within wicket:child/ tag. RepeatingView comes in handy. It allows me to reserve some places in base component markup and put something there in subclasssing component markup. I saw examples of that in some projects when studying Wicket. So I just copy the idea without thinking about WHEN to call the overridden method that fills in the RepeatingView instance. It is my fault :) If you add name attribute to wicket:child tag, and multiple wicket:extend name=... tags I would use it instead of RepeatingView. Concerning your post on onBeforeRender ... I didn't say that it is related to class' constructor. Yes it is related to delayed component creation. And the reason why I delay creation is to follow mentioned rule. It is not related to use of models in my case. I delay creation to allow subclassing components to replace some default parts of base component. Probably I'm doing something wrong. Then suggest me how to do it right. For instance I would like to subclass NatigationToolbar in DefaultDataTable. What should I do? Jeremy Thomerson-5 wrote: Do you have any examples of where Wicket calls an overridable method from the constructor of a Wicket class? If so, please file it as a JIRA - that would be a bug. Most java programmers know not to call overridable methods from the constructor as a general rule, although there are times when it could inadvertantly happen - which is why we need bug reports if you see that happening. -- Jeremy Thomerson http://www.wickettraining.com On Fri, May 15, 2009 at 12:01 AM, Vladimir K koval...@gmail.com wrote: Martijn, here Java is not safe as a language. Yo're able to invoke overrided methods on non-completely constructed objects. from my perspective it is a regular case in Wicket: class SampleComponent extends ... { String parameter; SampleComponent(String id, String parameter) { super(id); this.parameter = parameter; } // method is called from within superconstructor �...@override void createAdditionalComponents(RepeatingView rv) { useSomehow(parameter); } } I know two approaches to work around: - onBeforeRender - a closure as a constructor formal parameter. But the latter does not help with built-in components. If Wicket does not help us with adding appropriate method for second-step-initialization it should document it in wiki, javadoc and books dear user, when overriding methods, beware using of yet unassigned constructor parameters. Hmm ... sounds stupid :) Martijn Dashorst wrote: This has been discussed till death previously and we have excluded it from our roadmap. We will never have an init() method for components. Gossling gave us a Constructor to initialize your Objects. Search and read the archives if you want more information on the subject. Martijn On Fri, May 15, 2009 at 12:36 AM, Juan G. Arias juangar...@gmail.com wrote: It would be very nice to add a new phase for component creation, like I said, an init() or createContent(). Is there a JIRA issue for that? If yes, I will vote for it and suggest to change the name to something _not_ related to the rendre phase. Thanks! Juan On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch daniel.st...@gmail.comwrote: I think you can use hasBeenRendered() method instead of custom boolean flag. -- Daniel On 2009-05-14, at 20:15, Jeremy Thomerson wrote: You could probably do it in onBeforeRender - but you would need to keep a boolean flag to check if it's the first render so that you don't recreate them on a second render There was talking of adding an onBeforeFirstRender method, but I don't think it's happened yet - you could look for the method to see if I'm wrong. -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - 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://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.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