【问题标题】:Primefaces editor in a dialog doesn't works对话框中的 Primefaces 编辑器不起作用
【发布时间】:2013-02-05 15:15:10
【问题描述】:

我有一个对话框来插入一些字段,其中一个是 p:editor,它显示为好像它被禁用而它不是。一个奇怪的“真”字符串显示在编辑器主体中。 代码:

<p:dialog id="insertPanel" header="Inserisci" widgetVar="dlg1" appendToBody="true" modal="true">
  <h:form id="insertForm">
    <h:panelGrid columns="2">
      <h:outputLabel value="Nome: " for="name" />
      <p:inputText id="name" value="#{controller.name}" />
      <h:outputLabel value="Oggetto: " for="subject" />
      <p:inputText id="subject" value="#{controller.subject}" />
      <h:outputLabel value="Visibilità: " for="visibility" />
      <p:inputText id="visibility" value="#{controller.visibility}" />
      <h:outputLabel value="Testo: " for="text" />
      <p:editor id="text" value="#{controller.text}" width="600"/>
      <f:facet name="footer">
        <p:commandButton actionListener="#{controller.insert}" value="Inserisci" />
      </f:facet>
    </h:panelGrid>
  </h:form>
</p:dialog>

显示问题的对话框图像:

如您所见,编辑器就像被禁用并在其正文中显示“true”。

【问题讨论】:

  • 如果有帮助,我注意到如果我按下插入按钮而不插入其他字段,表单会返回验证错误,然后编辑器才开始工作!我不明白为什么!
  • 您是否将&lt;p:dialog&gt; 放置在任何其他PrimeFaces 组件中,例如&lt;p:layout&gt;
  • 是的,它在&lt;p:layout&gt; 中,但有appendToBody="true",它应该不会修复任何问题?
  • 这里我们有一个类似的问题stackoverflow.com/questions/24743084/…,但在这种情况下是重新渲染编辑器时

标签: jsf-2 primefaces editor


【解决方案1】:

我解决了这个问题。 我刚刚将update=":insertForm" 放入打开对话框的commandButton 中,它就可以工作了。

<p:commandButton id="insertButton" value="Inserisci" oncomplete="dlg1.show();" update=":insertForm" />

【讨论】:

  • 您好,感谢您分享解决方案。你知道为什么它只有在你更新表单时才有效吗??
【解决方案2】:

尝试在对话框组件中添加showEffect="fade"

【讨论】:

  • 请详细解释可能的原因是什么以及为什么您认为这是解决方案。这个答案在其他方面没有帮助/无用,最好作为评论发布。
  • 由于声誉低,我还不能添加 cmets :( 我之前遇到过同样的问题,并通过在 primefaces 论坛forum.primefaces.org/… 上查看以下答案解决了这个问题@
  • 这对我有用。很奇怪。找到原因了吗?
  • 我在效果幻灯片的问题中遇到了同样的问题。当我删除效果或将其更改为淡入淡出效果时,它会起作用。很奇怪。
  • 奇怪的是,这对我有用,我使用的是盲目效果,即使更新显示的组件,它也不起作用,改为淡入淡出效果,它起作用了。
猜你喜欢
  • 2013-09-10
  • 1970-01-01
  • 1970-01-01
  • 2013-07-02
  • 1970-01-01
  • 1970-01-01
  • 2013-02-19
  • 2014-12-24
  • 2013-08-14
相关资源
最近更新 更多