5 Replies Latest reply on Feb 7, 2013 7:39 AM by semubiz

    Ajax render of RichFaces 4.1.0 M1 rich:editor

    Alexandre Lavoie Newbie

      Hi,

       

      I was glad to see the component rich:editor again so I've tested it to upgrade existing website from RichFaces 3.3.3 to 4.1.0 M1. Unfortunatly, it looks like the rich:editor has not been designed to be rendered by ajax action ie :

       

      <a4j:commandButton value="Show editor" actionListener="#{bean.activateShow}" render="panel" />

       

      <h:panelGroup id="panel">

           <rich:editor rendered="#{bean.editorVisible}" />

      </h:panelGroup>

       

      I've saw that this componant had the following code in the <body> :

       

      <body onpageshow="event.persisted && (function(){var allInstances = CKEDITOR.instances, editor, doc;for ( var i in allInstances ){     editor = allInstances[ i ];     doc = editor.document;     if ( doc )     {          doc.$.designMode = "off"; doc.$.designMode = "on";     }}})();">

       

      So i've tried something like

       

      <script>

           function reloadEditors()

           {

                var allInstances = CKEDITOR.instances, editor, doc;for ( var i in allInstances ){     editor = allInstances[ i ];     doc = editor.document;     if ( doc )     {          doc.$.designMode = "off"; doc.$.designMode = "on";     }}

           }

      </script>

       

      and add oncomplete="reloadEditors()" to the a4j:commandButton but it doesn't work much more.

       

      Anyone tried this component?

       

      Thank you,

       

      Alexandre.

        • 1. Re: Ajax render of RichFaces 4.1.0 M1 rich:editor
          Brian Leathem Master

          Hi Alexandre,

           

          Thanks for trying out the new editor component!  I believe the rerender issue you are describing is a known problem, and is scheduled to be addressed for the M2 release.  See:

          https://issues.jboss.org/browse/RF-11230

           

          If I've mis-interpreted the problem you are describing, please let me know.

           

          Brian

          1 of 1 people found this helpful
          • 2. Re: Ajax render of RichFaces 4.1.0 M1 rich:editor
            Alexandre Lavoie Newbie

            Thank you Brian, good point I'll wait for this version. Keep doing that great work on this amazing framework!

             

            Alex.

            • 3. Re: Ajax render of RichFaces 4.1.0 M1 rich:editor
              Przemysław Dębski Newbie

              Hi,

              I used two builds of M2, one from 24/Aug/11 (day after issue RF-11230 had been resolved) and one from yesterday (08/Sep/11) and still there is a problem with rendering editor after AJAX action... It seems like editor is still caches and it's rendered after full page rendering so the AJAX action which updates just a part of the view does not init editor and it doesn't appear... Will it work on final M2 release?

               

              Przemek

              • 4. Re: Ajax render of RichFaces 4.1.0 M1 rich:editor
                semubiz Newbie

                Works  with RichFaces 4.1.0.Final. Yet there is still a bug: The rich:editor has to be rendered the first time the page is displayed. After that it can be hidden and shown with AJAX.

                 

                <h:selectOneMenu value="#{pageControllerBean.pageType}">

                <f:selectItems value="#{pageControllerBean.pageTypes}" />

                <a4j:ajax event="valueChange" render="editorPanel" execute="@this" />

                </h:selectOneMenu>

                <a4j:outputPanel id="editorPanel" layout="block">

                <rich:editor rendered="#{pageControllerBean.htmlPage}" />

                </a4j:outputPanel>

                • 5. Re: Ajax render of RichFaces 4.1.0 M1 rich:editor
                  semubiz Newbie

                  Conditional Ajax-Rerender of rich:editor still does not work (checked RF 4.2.3).

                   

                  As a workaround, I added a dummy rich:editor which is not displayed, but  initializes the CKEditor javascript. The other editor will be rendered conditionally as expected.

                   

                  <!-- Dummy Editor added to initialize CKEditor-javascript on load. without this, the text or html editor won't be rendered after type change -->

                  <rich:editor id="dummyEditor" />

                  <!-- Hide the editor immediately -->

                  <rich:jQuery selector="#dummyEditor" query="hide()" />

                   

                  <h:selectOneMenu value="#{pageControllerBean.pageType}">

                       <f:selectItems value="#{pageControllerBean.pageTypes}" />

                       <a4j:ajax event="valueChange" render="editorPanel" execute="@this" />

                  </h:selectOneMenu>

                  <a4j:outputPanel id="editorPanel" layout="block">

                  <rich:editor rendered="#{pageControllerBean.htmlPage}" />

                  </a4j:outputPanel>