IFrame方法.getBody返回null

时间:2018-10-08 09:25:17

标签: javascript java iframe gwt ckeditor

我在GWT项目中使用CKEditor,其中我在单个UI中使用4 CKEditor。更改dropDown时,将更改CKEditor文本字段的值。

@GetMapping(value="/{id}", params="form")
public String updateForm(@PathVariable(value="id") final Long id, final Model uiModel) {

    AbstractUser user = userService.findById(id);

    if(user instanceof Administrators) {
        Administrators u = (Administrators) user;
        uiModel.addAttribute(USER, u);

    }else if (user instanceof Commercial){
        Commercial ut = (Commercial) user;

        uiModel.addAttribute(USER, ut);
    }

    return UPDATE_PAGE;
}

此处IFrameElement iframe = (IFrameElement) element; iframe.getContentDocument().getBody().setInnerText(value); 返回文档,但是iframe.getContentDocument()返回null。

在前两个ckeditor iframe.getContentDocument().getBody()上,它们可以正常工作,但对于后两个,     iframe.getContentDocument().getBody()返回null。因此出现错误

未捕获的TypeError:无法将属性'textContent'设置为null     在DOMImplWebkit_1_g $ .setInnerText_2_g $ [作为setInnerText_6_g $]处。...

1 个答案:

答案 0 :(得分:2)

我希望您正在将值设置为空白(“”)来处理空指针问题。