• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic