from Component.java in 1.5 (trunk)

        /**
         * Callback method invoked after the component was added to its
parent AND you can walk up the
         * hierarchy up until the Page. That is, all parents must be have
been added to their parents as
         * well. Add this point in time {...@link #getMarkup() getMarkup} is
guaranteed to be available.
         * <p>
         * This method is guaranteed to called only once
         * </p>
         * <p>
         * If you don't like constructors to initialize your component, this
is the method to use.
         * </p>
         */
        protected void onInitialize()
        {
        }

-igor

On Fri, Apr 2, 2010 at 2:03 PM, Joseph Pachod
<josephpac...@thomas-daily.de> wrote:
> hi
>
> The other day, I was busy creating reusable components. To make them "safe", 
> I used what I believe is a wicket good practices: adding the components in 
> onBeforeRender.
>
> In fact, it's not just in onBeforeRender, it's rather :
>       �...@override
>        protected void onBeforeRender() {
>            if(!hasBeenRendered()){
>                // actual code
>            }
>            super.onBeforeRender();
>        }
>
> having done this stuff repeatedly, I felt a bit annoyed but these many   " 
> if(!hasBeenRendered())" and the brackets/indentations it brings.
> Furthermore, on the few occasions I really needed something done on each 
> onBeforeRender, it brought clutter to the code.
> Last but not least, recently, I was helping a wicket beginner and explaining 
> this "onBeforeRender/if(!hasBeenRendered)" wasn't the best moment I had.
>
> As such, I started to wonder if a simple "onInitialRender" method (or 
> similarly named) could be created ? It would run once and only once before 
> the first onBeforeRender.
>
> onBeforeRender would then return to what it should really mean (but still 
> have this handy hasBeenRendered() method just in case).
>
> In the end, it's trivial but would save a few keystrokes and bring some 
> clarity.
>
> What do you think of that ?
>
> thanks in advance
> joseph

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

Reply via email to