[Logo] IT Mill Toolkit Forum
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
When will com.itmill.toolkit.ui.AbstractComponent.getApplication return null?  XML
Forum Index -> General Help
Author Message
Johnny



Joined: 16/07/2008 17:44:11
Messages: 15
Offline

Hi,

Sometimes I need to get a handle to the Application object inside a CustomComponent but getApplication() returns null. Why is this? When will getApplication() return null and is there a way to get to the Application object when it does?

Thank you for your attention,

Johnny
QuentinAstegiano



Joined: 16/01/2008 15:10:43
Messages: 38
Location: Paris, France
Offline

Hmm...

Are you sure that when you do the .getApplication() , your component has been added to your application ?

getApplication() can only be called after the component is attached to the app.

Quentin.
Johnny



Joined: 16/07/2008 17:44:11
Messages: 15
Offline

Quentin,

Actually, at the time getApplication() is called, my CustomComponent is in the process of being added to a window - getApplication() is called in the CustomComponent's constructor. From what you write I can't call getApplication() there. So, how can I get hold of the application object in the constructor of a CustomComponent?

Best regards,

Johnny
QuentinAstegiano



Joined: 16/01/2008 15:10:43
Messages: 38
Location: Paris, France
Offline

Well... Calling getApplication() in the constructor is something that just do not work - well, at least it never worked for me :p
By definition, in the constructor of the CustomComponent, the component is not yet added to the application - and thus cannot access it.
If you really, really need that, maybe sending the application as constructor parameter ?

What I do when I need to init a component using the application is either to use a separate init method that I call after I added the component ; or on some tricky case, override the attach() method on the CustomComponent (calling super.attach() on the first line, and then doing all the specific init).

Quentin.
Johnny



Joined: 16/07/2008 17:44:11
Messages: 15
Offline

What I do when I need to init a component using the application is either to use a separate init method that I call after I added the component ; or on some tricky case, override the attach() method on the CustomComponent (calling super.attach() on the first line, and then doing all the specific init).  


Thanks, either should do the trick.

Best regards,

Johnny
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7 © JForum Team