Re: How do you use Custom Widgets (Composites) multiple times?
thats because the GWT Widget actually wraps a DOM Element, which is used to render to the browser. Consider simple plain HTML, where you want to render exactly same infoBox (let it be a Hello world) twice, at the top and at the bottom of the page, you're really going to have two different instances of Elements (Nodes), you cannot attach the same Element twice to the DOM. Though, you can use the same instance if you dont want to render it simultaneously, you can just "move" that Element in the DOM hierarchy to make it appear once at top, next time at the bottom... that's why you allways will have to create a new instance of a composite for each visual rendering. another approach is not to wrap the DOM Element, but instead to offer an API to render the contents into, the way like ExtGWT works, then you may have only one instance of a "Widget" i.e. holding complex data, and when rendering you just provide that Widget two different instances of DOM Elements that Widget will use to render its contents into. treat your Widget as "graphical" only, so for rendering and keep your data model outside, then there is no problem with multiple widget creation, consider reading MVP topic On 27 Nov., 21:09, Paul wrote: > I have added the new for each instance. I do not understand why I can > not add a composite multiple times. Does anyone know of a way to mimic > this behavior if this is not directly possible. If I need to have 50 > identical things on the page, having to create 50 manually is > ridiculous, I should be able to create one that I can use multiple > times. > > On Nov 23, 10:43 am, ep wrote: > > > what jhulford meant is that you really have to make a "new" on every > > widget class you add to any place. > > > On 22 Nov., 06:00, Paul wrote: > > > > Sorry if this is somewhere else and I missed it, but I have aCustom > > > Widget that I need to be able to addmultipletimesto anothercustom > > > widget I am creating. I do not seem to understand something about this > > > process and so I get the following errors: > > > > "Different parents for double associations" > > > "The other component is added to a parent component more than once." > > > > So basically, the first one gets nuked and only the second one shows > > > up. What am I missing? Can someone please assist me in understanding > > > what is wrong. Thank you so much in advance. Below is the code: > > > > public class FirstClass extends Composite > > > { > > > public FirstClass() > > > { > > > Image image = new Image("img/picture.png"); > > > AbsolutePanel element = new AbsolutePanel(); > > > > element.add(image, 0, 0); > > > > initWidget(element); > > > } > > > > } > > > > public class SecondClass extends Composite > > > { > > > public SecondClass() > > > { > > > HorizontalPanel element = new HorizontalPanel(); > > > > VerticalPanel elementA = new VerticalPanel(); > > > element.add(elementA); > > > > VerticalPanel elementB = new VerticalPanel(); > > > element.add(elementB); > > > > elementA.add(new FirstClass()); > > > elementB.add(new FirstClass()); > > > > initWidget(element); > > > } > > > > } -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: How do you use Custom Widgets (Composites) multiple times?
I have added the new for each instance. I do not understand why I can not add a composite multiple times. Does anyone know of a way to mimic this behavior if this is not directly possible. If I need to have 50 identical things on the page, having to create 50 manually is ridiculous, I should be able to create one that I can use multiple times. On Nov 23, 10:43 am, ep wrote: > what jhulford meant is that you really have to make a "new" on every > widget class you add to any place. > > On 22 Nov., 06:00, Paul wrote: > > > > > > > > > Sorry if this is somewhere else and I missed it, but I have aCustom > > Widget that I need to be able to addmultipletimesto anothercustom > > widget I am creating. I do not seem to understand something about this > > process and so I get the following errors: > > > "Different parents for double associations" > > "The other component is added to a parent component more than once." > > > So basically, the first one gets nuked and only the second one shows > > up. What am I missing? Can someone please assist me in understanding > > what is wrong. Thank you so much in advance. Below is the code: > > > public class FirstClass extends Composite > > { > > public FirstClass() > > { > > Image image = new Image("img/picture.png"); > > AbsolutePanel element = new AbsolutePanel(); > > > element.add(image, 0, 0); > > > initWidget(element); > > } > > > } > > > public class SecondClass extends Composite > > { > > public SecondClass() > > { > > HorizontalPanel element = new HorizontalPanel(); > > > VerticalPanel elementA = new VerticalPanel(); > > element.add(elementA); > > > VerticalPanel elementB = new VerticalPanel(); > > element.add(elementB); > > > elementA.add(new FirstClass()); > > elementB.add(new FirstClass()); > > > initWidget(element); > > } > > > } -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: How do you use Custom Widgets (Composites) multiple times?
That above code does not work. I have tried it exactly. The only part I removed was the import statements. On Nov 23, 10:22 am, jhulford wrote: > You can't do what you're asking. A widget instance can only be added > to a single parent container. > > The code you posted looks ok though, so I'm guessing you probably have > a typo in your real code where you're trying to add the same instance > of FirstClass to elementA and elementB, which will cause the error > you're describing. > > On Nov 22, 12:00 am, Paul wrote: > > > > > > > > > Sorry if this is somewhere else and I missed it, but I have aCustom > > Widget that I need to be able to addmultipletimesto anothercustom > > widget I am creating. I do not seem to understand something about this > > process and so I get the following errors: > > > "Different parents for double associations" > > "The other component is added to a parent component more than once." > > > So basically, the first one gets nuked and only the second one shows > > up. What am I missing? Can someone please assist me in understanding > > what is wrong. Thank you so much in advance. Below is the code: > > > public class FirstClass extends Composite > > { > > public FirstClass() > > { > > Image image = new Image("img/picture.png"); > > AbsolutePanel element = new AbsolutePanel(); > > > element.add(image, 0, 0); > > > initWidget(element); > > } > > > } > > > public class SecondClass extends Composite > > { > > public SecondClass() > > { > > HorizontalPanel element = new HorizontalPanel(); > > > VerticalPanel elementA = new VerticalPanel(); > > element.add(elementA); > > > VerticalPanel elementB = new VerticalPanel(); > > element.add(elementB); > > > elementA.add(new FirstClass()); > > elementB.add(new FirstClass()); > > > initWidget(element); > > } > > > } -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: How do you use Custom Widgets (Composites) multiple times?
what jhulford meant is that you really have to make a "new" on every widget class you add to any place. On 22 Nov., 06:00, Paul wrote: > Sorry if this is somewhere else and I missed it, but I have a Custom > Widget that I need to be able to add multiple times to another custom > widget I am creating. I do not seem to understand something about this > process and so I get the following errors: > > "Different parents for double associations" > "The other component is added to a parent component more than once." > > So basically, the first one gets nuked and only the second one shows > up. What am I missing? Can someone please assist me in understanding > what is wrong. Thank you so much in advance. Below is the code: > > public class FirstClass extends Composite > { > public FirstClass() > { > Image image = new Image("img/picture.png"); > AbsolutePanel element = new AbsolutePanel(); > > element.add(image, 0, 0); > > initWidget(element); > } > > } > > public class SecondClass extends Composite > { > public SecondClass() > { > HorizontalPanel element = new HorizontalPanel(); > > VerticalPanel elementA = new VerticalPanel(); > element.add(elementA); > > VerticalPanel elementB = new VerticalPanel(); > element.add(elementB); > > elementA.add(new FirstClass()); > elementB.add(new FirstClass()); > > initWidget(element); > } > > } -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: How do you use Custom Widgets (Composites) multiple times?
You can't do what you're asking. A widget instance can only be added to a single parent container. The code you posted looks ok though, so I'm guessing you probably have a typo in your real code where you're trying to add the same instance of FirstClass to elementA and elementB, which will cause the error you're describing. On Nov 22, 12:00 am, Paul wrote: > Sorry if this is somewhere else and I missed it, but I have a Custom > Widget that I need to be able to add multiple times to another custom > widget I am creating. I do not seem to understand something about this > process and so I get the following errors: > > "Different parents for double associations" > "The other component is added to a parent component more than once." > > So basically, the first one gets nuked and only the second one shows > up. What am I missing? Can someone please assist me in understanding > what is wrong. Thank you so much in advance. Below is the code: > > public class FirstClass extends Composite > { > public FirstClass() > { > Image image = new Image("img/picture.png"); > AbsolutePanel element = new AbsolutePanel(); > > element.add(image, 0, 0); > > initWidget(element); > } > > } > > public class SecondClass extends Composite > { > public SecondClass() > { > HorizontalPanel element = new HorizontalPanel(); > > VerticalPanel elementA = new VerticalPanel(); > element.add(elementA); > > VerticalPanel elementB = new VerticalPanel(); > element.add(elementB); > > elementA.add(new FirstClass()); > elementB.add(new FirstClass()); > > initWidget(element); > } > > } -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
How do you use Custom Widgets (Composites) multiple times?
Sorry if this is somewhere else and I missed it, but I have a Custom Widget that I need to be able to add multiple times to another custom widget I am creating. I do not seem to understand something about this process and so I get the following errors: "Different parents for double associations" "The other component is added to a parent component more than once." So basically, the first one gets nuked and only the second one shows up. What am I missing? Can someone please assist me in understanding what is wrong. Thank you so much in advance. Below is the code: public class FirstClass extends Composite { public FirstClass() { Image image = new Image("img/picture.png"); AbsolutePanel element = new AbsolutePanel(); element.add(image, 0, 0); initWidget(element); } } public class SecondClass extends Composite { public SecondClass() { HorizontalPanel element = new HorizontalPanel(); VerticalPanel elementA = new VerticalPanel(); element.add(elementA); VerticalPanel elementB = new VerticalPanel(); element.add(elementB); elementA.add(new FirstClass()); elementB.add(new FirstClass()); initWidget(element); } } -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.