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

    rich:editor  and save button

    trossmy

      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}"/>
      ....
      </rich:editor>
      

      I seem to run into a deadlock.

        • 1. Re: rich:editor  and save button

          Hi,

          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,|,
           fontselect,fontsizeselect,|,
           search,replace,|,
           cut,copy,paste,selectall"/>
           <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" />
           </rich:editor>
          


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

           <a4j:jsFunction name="saveText"
           action="#{angTextController.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
            trossmy

            thanx Dave, this works partly

             <a4j:jsFunction name="saveText"
             action="#{jsfAction.save}"
             oncomplete="alert('saved')"/>
             <rich:editor value="#{jsfAction.text}" id="ediText" autoResize="true" width="800"
             theme="advanced" plugins="save,paste">
             <f:param name="theme_advanced_buttons1"
             value="save,bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,cut,copy,paste,undo,redo,link,unlink,image,cleanup,help,code,hr,removeformat,sub,sup,forecolor,backcolor,forecolorpicker,backcolorpicker,charmap,visualaid,anchor,newdocument,blockquote,separator"/>
             <f:param name="theme_advanced_buttons2"
             value="formatselect,fontselect,fontsizeselect,styleselect"/>
             <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"/>
             </rich:editor>
            

            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)


            • 3. Re: rich:editor  and save button
              ilya_shaikovsky

              check a4j:log output.

              • 4. Re: rich:editor  and save button
                trossmy

                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

                  you action should not returns any outcomes.

                  • 6. Re: rich:editor  and save button
                    trossmy

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