[Solved] Not initialized class when content not visible. [message #906819] |
Sun, 02 September 2012 17:15 |
Hel Ral Messages: 2 Registered: September 2012 |
Junior Member |
|
|
I've got a setup coded out which correctly created 2 window parts:
part 1 contains a treelist of items you can pick from,
part 2 contains several tabs with information.
When I click on something from the tree in part 1 I get a nullpointer exception.
When I click on something after opening all the pages from part 2, it works as expected.
The classes that I use for filling in the content of the tabs are singletons, which know for which window they are created. When you select something in part 1, I send a refresh call to the other 2 windows which tells them to recreate themselves with information about the newly selected element.
But since at least 1 page in part 2 hasn't been opened yet, it cannot create the controls that that page has because the container value hasn't been injected yet...
All pages from part 2 contain the following structure:
@Singleton
public class Page {
public static Page instance;
private Composite parent;
public Page() {
instance = this;
}
private void clear(){
panel.dispose();
createPanel();
}
@Inject
public void init(Composite parent) {
this.parent = parent;
createPanel();
}
private void createPanel() {
panel = new Composite(parent, SWT.NONE);
// column creation code
}
private void register(RowProvider row){
// row information code
}
public void update(InfoObject infoObject){
clear();
// register the RowProviders used on this page
}
when something in part 1 is selected, the update method is called with the selected infoObject.
is there a way to always create the normally hidden tabs so that they do have their content containers at startup, and that they do call the inject method init?
[Updated on: Mon, 03 September 2012 16:37] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06061 seconds