ICEfaces
  1. ICEfaces
  2. ICE-6647

inputRichText interferes with fileEntry

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      ICEfaces 2 Compat + ACE

      Description

      Forum user found that having an inputRichText component in the same form as a fileEntry causes the fileEntry not to work.

      After investigation, I can see that inputRichText with saveOnSubmit="true" does interfere with the form onsubmit mechanism that fileEntry relies upon.

      In Firebug, I can see this for the form:

      <form onsubmit="return false;" action="javascript:;" .../>

      Which would definitely mess things up. As well, in the Javascript, I've found the offending code that stomps over the onsubmit:

      icefaces2/compat/components/src/main/java/com/icesoft/faces/component/inputrichtext/fckeditor_ext.js
      Lines 139 - 157

      function FCKeditor_OnComplete(editorInstance) {
          var onCompleteInvoked = Ice.Prototype.$(editorInstance.Name + 'onCompleteInvoked');
          var fieldWithClientId = Ice.Prototype.$(editorInstance.Name);
          if (fieldWithClientId) {
              fieldWithClientId["jsInstance"] = editorInstance;
          }
          if (onCompleteInvoked)onCompleteInvoked.value = true;
          Ice.FCKeditorUtility.updateValue(editorInstance.Name);
          editorInstance.LinkedField.form.onsubmit = function() {
              return FCKeditorSave(editorInstance);
          }
          if (fieldWithClientId["AppfocusRequested"]) {
              try {
                  editorInstance.Focus();
              } catch (e) {
                  logger.info(e);
              }
          }
      }

      The FCKeditorSave(-) function basically does an iceSubmit(form, element, new Object()); and then returns false, to disable the browser's submit.

      Most of the rest of the code seems to be involved in updating a hidden input field from other javascript event, likely so that any other ICEfaces partial or full XHR submit will have the correct value. This part or doing an iceSubmit, and returning false, seems unnecessary in any context. Maybe there's some edge case, or we just assumed it would be better to AJAXify the response. It would also stomp over our regular non-fileEntry onsubmit interception, but does something similar, so maybe that's why we haven't noticed.

        Activity

        Hide
        Ken Fyten added a comment -

        Let's remove the onSubmit override behaviour and test to see that it still works as expected.

        Show
        Ken Fyten added a comment - Let's remove the onSubmit override behaviour and test to see that it still works as expected.
        Hide
        yip.ng added a comment -

        "Save" (floppy disk icon) doesn't work anymore if onsubmit override commented out. Nothing shows up in backing bean values box.

        (Be sure to do complete clean build before each testing.)

        Show
        yip.ng added a comment - "Save" (floppy disk icon) doesn't work anymore if onsubmit override commented out. Nothing shows up in backing bean values box. (Be sure to do complete clean build before each testing.)
        Hide
        Mark Collette added a comment -

        Maybe we can make the save button just directly do a partial submit, instead of doing a full form submit that we then have to intercept.

        Show
        Mark Collette added a comment - Maybe we can make the save button just directly do a partial submit, instead of doing a full form submit that we then have to intercept.
        Hide
        yip.ng added a comment -

        Callback attached to Save command instead.

        Revision: 24121


        Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/inputrichtext/fckeditor_ext.js

        Show
        yip.ng added a comment - Callback attached to Save command instead. Revision: 24121 Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/inputrichtext/fckeditor_ext.js
        Hide
        yip.ng added a comment -

        Added saveOnSubmit and submit button. Value saved successfully when submit button clicked. See screenshot 1.

        Show
        yip.ng added a comment - Added saveOnSubmit and submit button. Value saved successfully when submit button clicked. See screenshot 1.
        Hide
        yip.ng added a comment -

        Added another editor instance. Both values saved successfully when submit button clicked. See screenshot 2.

        Show
        yip.ng added a comment - Added another editor instance. Both values saved successfully when submit button clicked. See screenshot 2.
        Hide
        yip.ng added a comment -

        From Ken:

        If you have 2 on the form without saveOnSubmit = true, does only the one with the save button clicked on it save?

        Show
        yip.ng added a comment - From Ken: If you have 2 on the form without saveOnSubmit = true, does only the one with the save button clicked on it save?
        Hide
        yip.ng added a comment -

        Yes. But the other reverts to the old value.

        Show
        yip.ng added a comment - Yes. But the other reverts to the old value.
        Hide
        Ken Fyten added a comment -

        That's to be expected if they are in the same form. Can this JIRA be marked Resolved now?

        Show
        Ken Fyten added a comment - That's to be expected if they are in the same form. Can this JIRA be marked Resolved now?

          People

          • Assignee:
            yip.ng
            Reporter:
            Mark Collette
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: