最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - SmartGWT, appending HTML to HTMLPane - Stack Overflow

programmeradmin8浏览0评论

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.

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.

Share Improve this question edited Jan 2, 2012 at 4:37 Blessed Geek 21.7k25 gold badges109 silver badges179 bronze badges asked Mar 2, 2010 at 12:45 ChristopherChristopher 511 silver badge2 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 1

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.

You need to be setting canSelectText in the right place, not on the Window as a whole (which would include the header and icons), but just on the element where selection is allowed.

So two options:

1) when you add a plain GWT widget to a SmartGWT container it's auto-wrapped with a WidgetCanvas. You can wrap it yourself and setCanSelectText() on the WidgetCanvas.

http://www.smartclient./smartgwtee/javadoc//smartgwt/client/widgets/WidgetCanvas.html

2) subclass Canvas and override getInnerHTML() to return a DIV or other element with a known ID, and then use GWT's low-level DOM manipulation APIs to manipulate it's content.

Issue was solved by isomorphic on:

http://forums.smartclient./showthread.php?p=39351#post39351

发布评论

评论列表(0)

  1. 暂无评论