【问题标题】:InputRichText - how to use Icefaces InputRichText?InputRichText - 如何使用 Icefaces InputRichText?
【发布时间】:2013-03-25 21:21:43
【问题描述】:

我正在使用 ice:inputRichText。我想获取选定的文本-这与客户端有关,我的意思是-在服务器端对其进行操作并将其放回编辑器(与选定的位置相同)。您能否建议我一些最佳实践 - 如何使用此 JSF 组件?

非常感谢。


我还是不明白,ice:inputRichText 是如何工作的。目前,我在 CKEDITOR 和服务器之间的通信方面遇到了一个大问题。

我有一个带有 onclick 操作和服务器操作的 commandLink。 onclick 操作从 CKEDITOR 中获取选定的文本并将其放入隐藏字段。然后我可以在服务器端操作它。第一次它工作正常。但是在动作之后 inputRichText 组件正在刷新(或类似的东西),然后不可能重复该动作(仅启动 onclick 部分,也不启动服务器端)。如果我将 commandLInk 标记中的 immediate 属性设置为 true,它可以工作,但是我失去了我的应用程序的一些功能。所以我说,ice:inputRichText 的上下文中存在一些验证错误。你能给我建议吗?

谢谢!

【问题讨论】:

    标签: javascript jsf components ckeditor icefaces-1.8


    【解决方案1】:

    IceFaces 将负责更新来自服务器端客户端编辑器的数据,您可以在服务器端执行操作并将值绑定保留在 xhtml 中,IceFaces 将负责在客户端显示服务器端所做的更改。

    这里是一个如何使用icefaces富文本编辑器的例子。

    <ice:inputRichText id="inptTxtSelected" value="#{mybean.note}"
          rendered="#{!empty mybean.note}"
          height="295px" toolbar="editorToolbar" width="625px"
          customConfigPath="/templates/js/richTextEditorConfig.js" saveOnSubmit="true"/>
    

    您可以使用richTextEditorConfig.js 配置编辑器上的按钮

    CKEDITOR.editorConfig = function(config) {
            config.toolbarCanCollapse = false;
            config.resize_enabled = false;
        config.toolbar = 'editorToolbar';
        config.height ='180px';
        config.baseFloatZIndex = 20000; 
        config.resize_maxWidth = "100%";    
        config.uiColor = '#E4E8F7';
        config.skin='office2003';
        config.toolbar_editorToolbar = [
     ['Preview','-','Link','Unlink','-','Bold','Italic',
           'Underline','- ','NumberedList','BulletedList']        
    ];
    };
    

    你的 Bean 应该有类似的值,

    public class MyBean {
    
        private String note;
        //getter and setter to follow
    
        public void manipulateText(ActionEvent e){ 
            note = "set from server";
        }
    }
    

    【讨论】:

    • 非常感谢!如果我想用选定的文本做点什么,我将通过方法 void 操作文本的参数 ActionEvent e 解决这个问题?
    • Note 变量已经绑定到组件,变量 note 的任何更改都会反映在您的编辑器上。如果您需要任何其他参数,则可以将其作为 f:param 或 f:attribute 传递
    • 但是如何在 inputRichText 中获取选中的文本呢?只能通过javascript,不是吗?
    • 是的,您需要编写一个 javascript 来捕获它并发送到服务器。 Icefaces 使用 CkEditor 。以下是一些可能对stackoverflow.com/questions/2385609/… 有所帮助的示例
    猜你喜欢
    • 2011-06-22
    • 2011-05-06
    • 1970-01-01
    • 1970-01-01
    • 2012-12-20
    • 2010-11-04
    • 1970-01-01
    • 2012-03-28
    • 2011-12-19
    相关资源
    最近更新 更多