Re: Java and HTML file
My previous code works fine inserting HTML code(the first message).
But when I want to add one or many child widgets, for example a
button, to an internal DIV of the HTML code injected it seems to be a
little complicated.
To get down under the HTML added you can use
- RootPanel.get("id") (after adding it to parent panel, not on
constructor)
- Get deeper with getElement().getElementsByTagName("xxx");
/**BEGIN CLASS**/
public class MyComposite extends Composite {
interface MyCompositeResource extends ClientBundle {
MyCompositeResource INSTANCE =
GWT.create(MyCompositeResource.class);
@Source("MyComposite.html")
TextResource html();
}
public MyComposite (){
initWidget(new HTML(INSTANCE.html().getText()));
VerticalPanel vp; // Add wigets inside
this.getElement().appendChild((vp = new
VerticalPanel()).getElement());
for(int i=0; i < 10; i++) vp.add( new Button("bt"+i));
//To add to an internal div
NodeList<Element> eles =
getElement().getElementsByTagName("div");
Element e = eles.getItem(0);
e.appendChild((vp = new VerticalPanel()).getElement());
for(int i=0; i < 10; i++) vp.add( new Button("bt2"+i));
}
}
/**END CLASS**/
Of there's another method, I'd like to know
On Sep 14, 2:04 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> I'm pretty sure that it should work. Have you tried it? Did it fail?
--
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-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home