丰富的事件'onsave':编辑器不会触发

时间:2013-11-26 14:15:33

标签: jsf-2 richfaces

我正在使用rich:editor在我的网页中实现某种前端编辑器。单击链接时,编辑器应该打开,保存编辑器的内容后,编辑器应该再次关闭。关闭编辑器我遇到onsave事件的问题。这是我的代码。

这是打开编辑器的链接,因为将属性bean.show设置为true。它运作正常:

<h:commandLink>
    ...
    <f:setPropertyActionListener value="true" target="#{bean.show}" />
</h:commandLink>

这是编辑器本身,仅在show求值为true时呈现:

<h:form>
    <rich:editor value="..." onsave="showEditor(false)" rendered="#{bean.show}" />
</h:form>

onsave事件应该关闭编辑器,方法是再次将show属性设置为false,但编辑器保持打开状态,因为未调用showEditor()

<a4j:jsFunction name="showEditor">
    <a4j:param name="param1" assignTo="#{bean.show}" />
</a4j:jsFunction>

我做错了吗?或者你有任何其他想法如何实现这一点?任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:1)

只需仔细检查:在版本richfaces 4.x中,根本没有onsave属性,但

  • 的OnInit
  • 的onblur
  • 的onfocus
  • ondirty
  • 平变化

在org.richfaces.component.UIEditor类中指出。如果您想使用f:ajax来激活编辑器,情况也是如此。

现在,编辑器中的“保存”图标只发送form.submit()或其他内容。因此,要么尝试在该事件上添加jsFunction,要么引入自己的保存按钮。

编辑:Richfaces 4使用基于javascript的CKEditor,因此如果您想覆盖其“保存”按钮,this forum entry regarding CKEditor's save implementation可能会对您有所帮助。

valueChangeListener可能是触发Bean.setShow(boolean show)财产的可能解决方案。

XHTML:

<rich:editor value="#{bean.editorValue}" 
             valueChangeListener="#{bean.valueChanged}" />
托管bean中的

方法:

public void valueChanged(ValueChangeEvent e) {
   // do the code to close the window here
}

valueChangeListener也适用于Richfaces 4.3,但也许在CKEditor的javascript中开始是更好的选择。

希望,这有助于...... L。