8 Replies Latest reply on Jan 23, 2009 8:25 AM by Ilya Shaikovsky

    What am i doing wrong in rich:editor and a4j:support?

    Jose Berardo Newbie

      Hi friends,

      First, thank you all for this very nice new feature in RichFaces.
      I'm trying do use rich:editor, but i'm geting problems with it.

      I have an h:inputText in a rich:dataTable with a4j:support inside to make ajax requests changes some field on my bean. I just changed it to rich:editor but a didn't see any support for the onblur event. So, i tried onsave, but my Firefox (FF 3.0 - Ubuntu 8.04) only gives me (when a tried ctrl+s or click on save button):

      too much recursion
      http://localhost:8080/testproject/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript
      Line 101

      My code is:

      <rich:editor width="200" autoResize="true" height="100" value="#{_question.title}" immediate="true" theme="advanced" plugins="save">
      <f:param name="theme_advanced_buttons1" value="bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,save"/>
      <f:param name="theme_advanced_buttons2" value=""/>
      <f:param name="theme_advanced_buttons3" value=""/>
      <f:param name="theme_advanced_buttons4" value=""/>
      <f:param name="theme_advanced_toolbar_location" value="top"/>
      <f:param name="theme_advanced_toolbar_align" value="left"/>
      <a4j:support event="onsave" ajaxSingle="true" />
      </rich:editor>
      


      So what i'm doing wrong?
      Is it possible to use onblur event?

        • 1. Re: What am i doing wrong in rich:editor and a4j:support?
          Jose Berardo Newbie

          Without a4j:support, it works fine, but only reloading all the page

          • 2. Re: What am i doing wrong in rich:editor and a4j:support?
            Jose Berardo Newbie

            How can I make ajax requests?
            I made a test with onsave attribute, but I don't know how it works.
            Just for a test, I did:

            <script type="text/javascript">
             <![CDATA[
             function testar() {
             alert('foi!');
             }
             ]]>
            </script>


            And onsave="testar()" in rich:editor tag.

            I've inserted editor inside a dataTable which brings only two registers, but my function testar() was called 5 or 6 times () and the two editors were changed to undefined.

            Can I use a4j:support or a have to use onsave attribute?
            How can I use onsave?
            Is there any other event, like onblur (the documentation cites only onchange, oninit, onsave and onsetup)?

            • 3. Re: What am i doing wrong in rich:editor and a4j:support?
              Ilya Shaikovsky Master

              1) all the event are standard tinyMCE callbacks. So just check their documentation.

              2) if you want to save it via a4j:support - check richfaces demo sample. preview done in this manner there.

              3) you could also add simple button or link "save" and save via the control .

              • 4. Re: What am i doing wrong in rich:editor and a4j:support?
                Jose Berardo Newbie

                Ok Ilya, thank you for your response.

                But, I'm having some troubles with the demo version.

                When I use the attribute:

                onsubmit="if (! #{rich:element('form:editorvalue')}) return false;"


                My editor doesn't appear in the view.

                My rich:editor id is editor too, but it is inside a rich:dataTable, so I believe I have to change the form:editorvalue, but I don't know what to use in replacement.

                My Code:

                <rich:dataTable rendered="#{perguntasAction.listaAberta}" value="#{perguntas}" var="_pergunta">
                 <rich:column>
                 <f:facet name="header">Title</f:facet>
                 <rich:editor id="editor" width="200" autoResize="true" height="50" value="#{_pergunta.titulo}" immediate="true" theme="advanced" plugins="save">
                 <f:param name="theme_advanced_buttons1" value="bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,save,cancel"/>
                 <f:param name="theme_advanced_buttons2" value=""/>
                 <f:param name="theme_advanced_buttons3" value=""/>
                 <f:param name="theme_advanced_buttons4" value=""/>
                 <f:param name="theme_advanced_toolbar_location" value="top"/>
                 <f:param name="theme_advanced_toolbar_align" value="left"/>
                 <f:param name="save_enablewhendirty" value="true"/>
                 <a4j:support event="onchange" ajaxSingle="true" requestDelay="1000" onsubmit="if (! #{rich:element('form:editorvalue')}) return false;"/>
                 </rich:editor>
                 </rich:column>
                </rich:dataTable>


                What am i doing wrong?

                • 5. Re: What am i doing wrong in rich:editor and a4j:support?
                  Ilya Shaikovsky Master

                  just remove this one. It was used at demo in order not to submit the form if the preview turned of.

                  • 6. Re: What am i doing wrong in rich:editor and a4j:support?
                    Jose Berardo Newbie

                    As far as I can see, my problem was about using event="onsave".
                    When I replace it by event="onchange" the editor passed to work.

                    With onsave, my browser throws a Too much recursion in firebug console. with onsave and requestDelay, simply nothing works (neither error).

                    Now, with onchange, it's ok. Thank you.

                    • 7. Re: What am i doing wrong in rich:editor and a4j:support?
                      Jose Berardo Newbie

                      Hi ilya.

                      Few days of testing and my editor seems to not work fine.
                      I found an issue even in editor at demo pages. Try to turn on the Toggle Preview and type a text (letters, spaces, numbers). It will not fire the request, only when you click or use arrows. Is it a bug?

                      In my codes, sometimes the editor simply stops ajax requests. Other times, it fires a "too much recursion" exception in firefox.

                      Code:

                      <rich:editor height="60" width="300" value="#{perguntasAction.perguntaAtual.titulo}" configuration="#{perguntasAction.editor}" id="titulo">
                       <a4j:support event="onsave" requestDelay="1000" reRender="questionsList" ignoreDupResponses="true" limitToList="true" ajaxSingle="true"/>
                      </rich:editor>


                      Properties (pseudo-code):
                      theme="advanced"
                      plugins="save ... and many others"
                      several buttons at four lines
                      save_enablewhendirty="true"


                      • 8. Re: What am i doing wrong in rich:editor and a4j:support?
                        Ilya Shaikovsky Master

                         

                        I found an issue even in editor at demo pages. Try to turn on the Toggle Preview and type a text (letters, spaces, numbers). It will not fire the request, only when you click or use arrows. Is it a bug?

                        Not a bug of rich editor. We just use the event which tinyMCE provides. We do not rewrite their basic functionality so the event works just as desinged in tinyMCE.

                        In my codes, sometimes the editor simply stops ajax requests. Other times, it fires a "too much
                        recursion" exception in firefox.


                        Need the details on the case.