6 Replies Latest reply on May 12, 2009 6:46 AM by Tilman Rossmy

    rich:editor  and save button

    Tilman Rossmy Newbie

      can I invoke a managedBean method (eg. #{someBean.save}) with the save button of the rich:editor componet? if I try this:

      <rich:editor ...
      <a4j:support event="onsave" action="#{someBean.save}"/>

      I seem to run into a deadlock.

        • 1. Re: rich:editor  and save button
          Stefan Kortmann Newbie


          you could make use of the "Save" button in rich:editor. For this, you have to add plugin "save" and can then set a callback routine on parameter "onsavecallback".

          Example of what I mean

           <rich:editor theme="advanced" plugins="paste,searchreplace,save" viewMode="visual" height="550" width="950"
           value="#{angTextController.text}" >
           <f:param name="theme_advanced_buttons1" value="bold,italic,underline,|,
           <f:param name="theme_advanced_buttons2" value="justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,insertdate,inserttime,|,hr,outdent,indent" />
           <f:param name="theme_advanced_buttons3" value="save,cancel" />
           <f:param name="save_enablewhendirty" value="true" />
           <f:param name="save_onsavecallback" value="saveText" />

          With f:param you set the callback routine, in this case "saveText" which must then be defined as a jsFunction.

           <a4j:jsFunction name="saveText"
           oncomplete="alert('saved')" />

          Like this you can call the bean method defined in "action" in order to save the text.

          Hope this helps.

          • 2. Re: rich:editor  and save button
            Tilman Rossmy Newbie

            thanx Dave, this works partly

             <a4j:jsFunction name="saveText"
             <rich:editor value="#{jsfAction.text}" id="ediText" autoResize="true" width="800"
             theme="advanced" plugins="save,paste">
             <f:param name="theme_advanced_buttons1"
             <f:param name="theme_advanced_buttons2"
             <f:param name="theme_advanced_buttons3" 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"/>
             <f:param name="save_onsavecallback" value="saveText"/>

            The action configured in the a4j:jsFunction tag gets executed in firefox and IE.
            Unfortunately the javascript from the oncomplete attribute does not execute in both browsers, the rich:message that is added by my jsfAction.save method only displays in firefox (firefox seems to perform a complete page refresh, while IE behaves ajaxlike, in this case not so nice, because the user does not get any feedback at all)

            • 4. Re: rich:editor  and save button
              Tilman Rossmy Newbie

              this is the IE / output:

              debug[11:43:21,687]: Have Event [object Object] with properties: target: undefined, srcElement: [object], type: click
              debug[11:43:21,687]: Query preparation for form 'termsandconditionsForm' requested
              debug[11:43:21,687]: Append hidden control termsandconditionsForm with value [termsandconditionsForm] and value attribute [termsandconditionsForm]
              debug[11:43:21,687]: Append select-one control termsandconditionsForm:sprache with value [GERMAN] and value attribute [GERMAN]
              debug[11:43:21,703]: Append textarea control termsandconditionsForm:ediTextTextArea with value [<p>TEST IE 7</p>] and value attribute [<p>TEST IE 7</p>]
              debug[11:43:21,703]: Append hidden control javax.faces.ViewState with value [j_id4] and value attribute [j_id4]
              debug[11:43:21,703]: parameter termsandconditionsForm:j_id56 with value termsandconditionsForm:j_id56
              debug[11:43:21,703]: Look up queue with default name
              debug[11:43:21,703]: NEW AJAX REQUEST !!! with form: termsandconditionsForm
              debug[11:43:21,703]: Start XmlHttpRequest
              debug[11:43:21,703]: Reqest state : 1
              debug[11:43:21,703]: QueryString: AJAXREQUEST=_viewRoot&termsandconditionsForm=termsandconditionsForm&termsandconditionsForm%3Asprache=GERMAN&termsandconditionsForm%3AediTextTextArea=%3Cp%3ETEST%20IE%207%3C%2Fp%3E&javax.faces.ViewState=j_id4&termsandconditionsForm%3Aj_id56=termsandconditionsForm%3Aj_id56&
              debug[11:43:22,265]: Reqest state : 2
              debug[11:43:22,265]: Reqest state : 3
              debug[11:43:22,265]: Reqest state : 4
              debug[11:43:22,265]: Reqest end with state 4
              debug[11:43:22,265]: Response with content-type: text/html; charset=UTF-8;charset=ISO-8859-1
              debug[11:43:22,296]: Header Ajax-Response not found, search in <meta>
              debug[11:43:22,296]: Header Ajax-Expired not found, search in <meta>
              warn[11:43:22,296]: No ajax response header
              debug[11:43:22,296]: Header Location not found, search in <meta>
              debug[11:43:22,312]: replace all page content with response
              debug[11:43:22,312]: setup custom document.open method
              debug[11:43:22,327]: exception during write page content undefined
              error[11:43:22,343]: Error parsing responseXML Parsing Error: DTD is prohibited.
              Location: Line Number 1, Column 11:
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
              debug[11:43:22,343]: page content has been replaced

              The firefox output gets cleared by the page refresh

              • 5. Re: rich:editor  and save button
                Ilya Shaikovsky Master

                you action should not returns any outcomes.

                • 6. Re: rich:editor  and save button
                  Tilman Rossmy Newbie

                  ok, cool, thanks ilya, now everything seems to work alright.