I have class A which extends an Abstract class B and that abstract class B extends Table.
When I run on my local machine, I can nicely view the table, when I deploy it to the development environment I get the error message saying class A already has a parent.
Hmm, the code actually throwing this IllegalStateException (this is the exception you get, isn’t it?) is pretty much straight forward. Look at com.vaadin.ui.AbstractComponent.setParent(HasComponents).
Did you check the stack trace? Maybe your component is being added to another component at some other point.
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:465)
at com.vaadin.ui.Table.registerComponent(Table.java:2376)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2363)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2173)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1694)
at com.vaadin.ui.Table.attach(Table.java:4171)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:479)
at com.vaadin.ui.CustomComponent.setCompositionRoot(CustomComponent.java:121)
at uk.co.sovini.flowmobile.views.LogoViewTemplate.enter(LogoViewTemplate.java:26)
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:571)
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:526)
I am only adding this tablecomponent only once. that is why i dont get the error in my local i think
I am sorry, I can’t see the actual error.
You are using the navigator. I don’t know exactly what happens but the stored View maybe could do something
Actually you are creating a new instance when adding the component, so your code seems correct. But does your IntelTable implement View and is being called by your NavigatorProvider? So you are adding the view manually and than the navigator is trying to add the view/table to the configured component. That
may be the case.
It implements an AbsstractTable which again the AbstractTable extends Table.
I saw one problem though
if (component.getParent() != this) {
component.setParent(this);
}
this is the - IntelsTable
And the component.getParent is a Vertical Layout and this is causing the problem. How can I set the parent in such a way this will result in true and would not go into the setParent method?
I am using a Table I have a generated column which in the class that generates the table.
if (component.getParent() != this) {
component.setParent(this);
}
results in illegalstate expection
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:465)
at com.vaadin.ui.Table.registerComponent(Table.java:2376)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2363)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2173)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1694)
at com.vaadin.ui.Table.attach(Table.java:4171)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:479)
at com.vaadin.ui.CustomComponent.setCompositionRoot(CustomComponen
The thing is I have a generated column in which I decided some color coding, however when I run the application it goes inside the below method and my table is in a vertical Layout and this is the TABLE it self. so it gives me that exception. I want to know how can I prevent from going inside that method?
if (component.getParent() != this) {
component.setParent(this);
}
It would be good if you will show
small isolated code which reproduce your problem. Is it possible? Can you create new small project where we can see your problem?
I did as you told me. It works on my local but on the development environement it gives me this error.
Any idea?
Caused by: java.lang.IllegalStateException: uk.co.sovini.flowmobile.views.components.tables.IntelsTable already has a parent.
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:465)
at com.vaadin.ui.Table.registerComponent(Table.java:2376)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2363)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2173)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1694)
at com.vaadin.ui.Table.attach(Table.java:4171)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.server.AbstractClientConnector.attach(AbstractClientConnector.java:583)
at com.vaadin.ui.AbstractComponent.attach(AbstractComponent.java:572)
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:479)
at com.vaadin.ui.CustomComponent.setCompositionRoot(CustomComponent.java:121)
at uk.co.sovini.flowmobile.views.LogoViewTemplate.enter(LogoViewTemplate.java:26)
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:571)
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:526)