• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

java.lang.IllegalStateException: This widget's parent does not implement HasWidgets

 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I'm loving GWT, but the Google Web Toolkit is kicking out this message when I run a new Composite class. Any quick hints?

-Cameron McKenzie
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ugh...I hate it when the error message actually tells you what is wrong!

java.lang.IllegalStateException: This widget's parent does not implement HasWidgets

Apparently, I was using a class that extends composite, as the books I’m reading suggest. But, if you do, apparently if you add the composite to another page as though it were a panel, well, that won’t work. Either I should have extended a Panel class for my composite container, or I need to implement the HasWidgets interface.

import com.google.gwt.user.client.ui.HasWidgets;

Apparently, these are the methods involved in the HasWidgets interaface. The actually look like they make sense:

@Override
public void add(Widget w) {
// TODO Auto-generated method stub
}

@Override
public void clear() {
// TODO Auto-generated method stub
}

@Override
public Iterator<Widget> iterator() {
// TODO Auto-generated method stub
return null;
}

@Override
public boolean remove(Widget w) {
// TODO Auto-generated method stub
return false;
}

I’m just going to leave them blank for now and see if it works.

 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, one of the problems I think I was having was the fact that I was constantly creating new components by extending Composite. What I'm really finding is that I should just be extending various Panel classes, like VerticalPanel, Grid, or even just extending MenuBar. From there, I can just access the 'this' of the component, configure the component directly, and other Google Web Toolkit Widgets can interact seamlessly with those components.

So, it seems that I could have avoided many of these problems by just extending some of the delicious GWT classes, as opposed to constantly creating Component classes.

Hope that helps someone else with similar growing pains.

-Cameron McKenzie
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.I was a little worried about the exception. I extended MenuBar and removed the initWidget method for my Horizontal split panel.
works
 
This parrot is no more. It has ceased to be. Now it's a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!