Joseph,
Could you elaborate on why adding components in onBeforeRender is "safe" and
a "wicket good practice"? I haven't come across this very often in my
projects. Under what circumstances would you recommend this approach?
josephpachod 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
>
--
View this message in context:
http://old.nabble.com/What-about-an-onInitialRender-method---tp28122954p28123309.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]