Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SmartGWT, appending HTML to HTMLPane

I am currently working with SmartGWT and have been trying to obtain a way of including a panel such as the gwt Standard VerticalPanel into a smart GWT window. The reason for the VerticalPanel is that I can append widgets to the verticalpanel object without having to re-set the entire content, for example:

HTMLPane hPaneObj = new HTMLPane();  
hPaneObj.setContents("Foo");

Now to append I can only see that I can do:

hPaneObj.setContents(hPaneObj.getContents() + "Bar");

which is not what I need.

The problem arises after I've added the VerticalPanel, I cannot select any text within the window even with the 'setCanSelectText' method called with true as the parameter. Below is a short example I put together:

 public void onModuleLoad() {
  Window theWindow = new Window();
  theWindow.setTitle("Good evening");
  theWindow.setWidth(500);
  theWindow.setHeight(500);
  theWindow.setCanSelectText(true);

  VerticalPanel vp = new VerticalPanel();
  vp.add(new HTML("foo"));
  vp.add(new HTML("bar"));
  theWindow.addItem(vp);
  Canvas canvas = new Canvas();
  canvas.addChild(theWindow);
  canvas.draw();
 }

I am quite suprised however that HTMLPane doesn't allow me to append without resetting the entire contents.

Any advice would be appreciated however I need to do be able to 'append' to a panel. I don't particularly like the idea of using a vertical panel however I need to either find a method of allowing the aforementioned or allowing me to allow the verticalpanel to be accessible, i.e. selecting the text.

Many thanks

Christopher.

like image 913
Christopher Avatar asked Nov 05 '22 15:11

Christopher


1 Answers

The VerticalPanel uses a html table to create it's content, and most likely not something you want in this case. In general, in HTML it's not possible to add plain HTML in addition to existing content, because of the xml like nature. For example if you have the following html <div>some text</div>. If you want to add text the point to add must be relative to the div tag, it's not possible to add something for example between some and text without reinserting that whole text.

In your case you might want to use FlowPanel (which is a div) and add the HTML with InlineHTML (which wraps the HTML with a span). In case you don't want the span wrapped you would have to reinsert the text as in your HTMLPane example.

like image 132
Hilbrand Bouwkamp Avatar answered Nov 12 '22 19:11

Hilbrand Bouwkamp