2

primefaces 富文本编辑器内联可见性故障:

如果单击命令按钮“打开/清除”(仅用于清除 bean 中的编辑器值),则编辑器将再次可见。

 <div id="multilanguage-descriptions">
   <p:inplace  styleClass="ui-multilanguage-description"
       id="ajaxInplace" widgetVar="inplaceeditorWidget" editor="true"
       toggleable="true" label="Edit" effect="slide" effectSpeed="fast">
 <p:editor  widgetVar="editorWidget" rendered="true"
       id="editor"  value="#{editorBean.value}" width="600"/>
  <p:commandButton  process="@this"
       ajax="true" value="Open/Clear" update="editor"
       id="clearButton"  action="#{editorBean.clearValue()}"/>

 </p:inplace>
</div>

在这种情况下,我很少使用 eclipse 插件,而是选择编写一个小的 main 方法来连接并运行它,或者编写一个可以暂停以检查状态或调试的单元测试。测试用例中嵌入式使用的jetty源码中有很多例子。

http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded

如果您选择研究此选项,这些示例可以帮助您继续前进。

4

1 回答 1

1

因为我遇到了同样的问题,而且我的一天没有别的事情要做(是的,我花了一整天的时间)我想通了(至少对我来说)。

问题在于正在更新的编辑器的容器(就地元素)。这会导致编辑器元素发生更新。编辑器有一个很大的缺点,那就是它的大小在渲染时是“硬编码”的。由于更新发生时编辑器被隐藏,因此编辑器未正确呈现。

我创建了一个示例来演示该问题:

<h:head>
</h:head>
<body>
    <h:form>
        <p:commandButton onclick="inplace.show()" icon="ui-icon-pencil" value="edit"/>
        <p:inplace widgetVar="inplace" >
            <p:editor id="editor"/>
            <p:commandButton onclick="inplace.cancel()" icon="ui-icon-cancel"
                value="cancel" />
            <p:commandButton onclick="inplace.save()" icon="ui-icon-disk" value="save" />
        </p:inplace>
    </h:form>
</body>

当您运行此示例时,您可以单击编辑按钮,然后事情会按预期工作。但是,如果您单击取消按钮(发生更新)然后再次单击编辑,则不会显示编辑器。

“解决方案”是强制更新编辑器。在示例中,您可以通过向编辑按钮添加更新来做到这一点:

<p:commandButton onclick="inplace.show()" icon="ui-icon-pencil" value="edit" update="editor"/>

由于更新,显示编辑器时会有一点延迟,但嘿,总比没有编辑器好。

于 2012-08-29T21:25:34.267 回答