tags:

views:

26

answers:

1

Hi,

I've been working with GWT for awhile, I can't find a way to integrate it with a preexisting website which is a real downer. My page content is already generated for me using jsp, like:

<div id='A'></div>
<div id='B'></div>
etc.

there is no way for me to do something like this though:

public void onModuleLoad() {

    SimplePanel spA = new SimplePanel( 
      Document.getElementById("A"));
    spA.add(new Label("hello"));


    SimplePanel spB = new SimplePanel( 
      Document.getElementById("B"));
    spB.setWidth("200px");

    etc ..
}

seems like there's no way to just wrap a pre-existing element. Is this true, or am I missing how to do this? I need be able to wrap a bunch of elements like this, to manipulate them later on. I see TextBox, Button, a few other classes have wrap() methods, however nothing like that exists for elements,

Thanks

+1  A: 

There is a way to wrap existing DOM elements, like Label's wrap() method. For example:

Label label = Label.wrap(DOM.getElementById("A"));
label.setText("Foo!");

Other GWT classes can wrap DOM elements too, like Button, and CheckBox using its constructor.

Jason Hall
Right wrap() methods exist for Label, Button, CheckBox, but FlowPanel and SimplePanel, do not have a wrap() method. Do you know of a way to support this? I basically just want to wrap a <div>.
You can do this with `RootPanel.get(...)` too.
Jason Hall
Ok thanks I will try to work with that, probably have a follow-up issue with this will open as a new Q, thank you.