Following code is used to set attribute style to body element and register cut/paste
code to it,but failed.Strangelly,when debugging,variable body is not null and attribute
"style" exists,but frame hasn't this child.Running work doesn't work as expected,and
NPE got thrown out when call setBodyContent()
public class TextAreaExt extends RichTextArea
{
private BodyElement body;
@Override
protected void onLoad()
{
super.onLoad();
body = ((FrameElement) getElement().cast())
.getContentDocument().getBody();
body.setAttribute("style", "color:gray;");
registerOnCut(body);
}
public void setBodyContent(String text)
{
body.setInnerText(text);
}
private native void registerOnCut(BodyElement element) /*-{
var that = this;
console.log("registerOnCut");
element.oncut = $entry(function(event) {
//invoke method to adjust height based on content
return false;
});
element.onpaste = $entry(function(event) {
//invoke method to adjust height based on content
return false;
});
}-*/;
}
Originally reported on Google Code with ID 7606
Reported by
Alexander.Luya
on 2012-08-20 00:52:16