Portlet in Blog tutorial: renderContent() vs. init()

Reading the blog tutorial i wondered, why it uses two different places to perform some “command” in a Portlet. In the menu portlet the logout command is performed in init(). But the login portlet uses renderContent() to check, if login has to be performed.

Whats the reason for that?

init() is the best place to put those code.

The reason for login portlet not doing so is because it tries to reuse the $form object. If we move the code to init(), we would need a class member to remember the $form object.

Ok, that solves the mistery :). Thanks.