ICEfaces
  1. ICEfaces
  2. ICE-5651

Need to support <f:ajax disabled="true"/>

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Alpha2
    • Fix Version/s: 2.0-Beta1, 2.0.0
    • Component/s: Framework, ICE-Components
    • Labels:
      None
    • Environment:
      ICEfaces 2.0 JSF 2.0
    • Affects:
      Compatibility/Configuration

      Description

      Standard JSF 2, by default, does not enable Ajax functionality in its components. The f:ajax tag is provided to indicate that you want a component (like a button or a whole form) to use Ajax techniques to submit information and update the interface. ICEfaces, by default, enables components to use Ajax but is also designed to work with the f:ajax tag so that certain behaviours can be modified through attributes on the tag. ICEfaces can also be disabled at the page-level so that standard JSF functionality can be configured on pages where ICEfaces and/or Ajax might not be desired.

      What is not currently supported with ICEfaces is disabling Ajax support at a more granular level - ie per component. The f:ajax tag has a 'disabled' attribute, which, if set to true, should disable Ajax features for that component. In these cases, the ICEfaces framework and components should respect when disabled=false and not provide Ajax functionality.

        Issue Links

          Activity

          Deryk Sinotte created issue -
          Hide
          Ted Goddard added a comment -

          <f:ajax> is described in the JSF 2.0 specification section 10.4.1.1 table 10-3.

          For the disabled attribute in particular:

          "false" indicates the Ajax behavior script should be rendered; "true" indicates the Ajax behavior script should not be rendered. "false" is the default.

          Show
          Ted Goddard added a comment - <f:ajax> is described in the JSF 2.0 specification section 10.4.1.1 table 10-3. For the disabled attribute in particular: "false" indicates the Ajax behavior script should be rendered; "true" indicates the Ajax behavior script should not be rendered. "false" is the default.
          Ken Fyten made changes -
          Field Original Value New Value
          Salesforce Case []
          Fix Version/s 2.0-Beta [ 10231 ]
          Assignee Ted Goddard [ ted.goddard ]
          Ken Fyten made changes -
          Link This issue blocks ICE-5008 [ ICE-5008 ]
          Ken Fyten made changes -
          Salesforce Case []
          Affects [Compatibility/Configuration]
          Assignee Priority P1
          Hide
          Ted Goddard added a comment -

          The following code dumps out the disabled state of the ajax behavior attached to a given component:

          import javax.faces.component.UIComponentBase;
          import javax.faces.component.behavior.ClientBehavior;
          import javax.faces.component.behavior.AjaxBehavior;

          Map <String, List <ClientBehavior>> behaviors = ((UIComponentBase) component).getClientBehaviors();
          AjaxBehavior behavior = (AjaxBehavior) behaviors.get("action").get(0);
          System.out.println("behaviors found " + behaviors);
          System.out.println("behavior " + behavior + " " + behavior.isDisabled());

          So, the <f:ajax> tag is not directly accessible itself, but it creates the AjaxBehavior Object attached to the component which does have an extensive API.

          Actual use of this API would need to iterate over all component behaviors and test for AjaxBehavior instances.

          Show
          Ted Goddard added a comment - The following code dumps out the disabled state of the ajax behavior attached to a given component: import javax.faces.component.UIComponentBase; import javax.faces.component.behavior.ClientBehavior; import javax.faces.component.behavior.AjaxBehavior; Map <String, List <ClientBehavior>> behaviors = ((UIComponentBase) component).getClientBehaviors(); AjaxBehavior behavior = (AjaxBehavior) behaviors.get("action").get(0); System.out.println("behaviors found " + behaviors); System.out.println("behavior " + behavior + " " + behavior.isDisabled()); So, the <f:ajax> tag is not directly accessible itself, but it creates the AjaxBehavior Object attached to the component which does have an extensive API. Actual use of this API would need to iterate over all component behaviors and test for AjaxBehavior instances.
          Hide
          Ted Goddard added a comment -

          This appears to work for both the nested and the wrapping forms:

          <f:ajax execute="button1" render="pg1 pg2" >
          <h:commandButton id="button1" value="Show/Hide"
          actionListener="#

          {basic.toggle}" >
          </h:commandButton>
          </f:ajax>


          <h:commandButton id="button1" value="Show/Hide"
          actionListener="#{basic.toggle}

          " >
          <f:ajax execute="button1" render="pg1 pg2" />
          </h:commandButton>

          Show
          Ted Goddard added a comment - This appears to work for both the nested and the wrapping forms: <f:ajax execute="button1" render="pg1 pg2" > <h:commandButton id="button1" value="Show/Hide" actionListener="# {basic.toggle}" > </h:commandButton> </f:ajax> <h:commandButton id="button1" value="Show/Hide" actionListener="#{basic.toggle} " > <f:ajax execute="button1" render="pg1 pg2" /> </h:commandButton>
          Hide
          Ted Goddard added a comment -

          <f:ajax disabled="true"/> must cause the "capture submit" behavior of the ICEfaces bridge to be disabled for that one component.

          HTML5 supports custom data-* attributes (which are frowned upon but not actually prohibited in HTML currently):

          http://dev.w3.org/html5/spec/elements.html#embedding-custom-non-visible-data

          For instance the bridge callback added by ice.captureSubmit() could check for the presence of data-ice-ajax="disabled" on the submitting element, and if present allow full-page form submission to proceed normally.

          Alternatively, the component could render JavaScript event callbacks that would set a flag, however this would result in verbose markup due to the variety of events that can cause form submission to occur.

          Show
          Ted Goddard added a comment - <f:ajax disabled="true"/> must cause the "capture submit" behavior of the ICEfaces bridge to be disabled for that one component. HTML5 supports custom data-* attributes (which are frowned upon but not actually prohibited in HTML currently): http://dev.w3.org/html5/spec/elements.html#embedding-custom-non-visible-data For instance the bridge callback added by ice.captureSubmit() could check for the presence of data-ice-ajax="disabled" on the submitting element, and if present allow full-page form submission to proceed normally. Alternatively, the component could render JavaScript event callbacks that would set a flag, however this would result in verbose markup due to the variety of events that can cause form submission to occur.
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21827 Wed Jun 30 16:11:41 MDT 2010 ted.goddard initial ajax disabled (ICE-5651)
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/resources/META-INF/faces-config.xml
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/javascript/application.js
          Commit graph ADD /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/event/AjaxDisabledList.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/event/FormSubmit.java
          Hide
          Ted Goddard added a comment -

          Part of the change to application.js required that the onsubmit callback not always be erased; it's not clear why this was necessary before.

          — core/src/main/javascript/application.js (revision 21816)
          +++ core/src/main/javascript/application.js (working copy)
          @@ -169,16 +169,21 @@
          f.submit = function()

          { submit(null, f); }

          ;

          • f.onsubmit = none;
            +// f.onsubmit = none;
            each(['onkeydown', 'onkeypress', 'onkeyup', 'onclick', 'ondblclick', 'onchange'], function(name) {
            f[name] = function(e) {
            var event = e || window.event;
          Show
          Ted Goddard added a comment - Part of the change to application.js required that the onsubmit callback not always be erased; it's not clear why this was necessary before. — core/src/main/javascript/application.js (revision 21816) +++ core/src/main/javascript/application.js (working copy) @@ -169,16 +169,21 @@ f.submit = function() { submit(null, f); } ; f.onsubmit = none; +// f.onsubmit = none; each( ['onkeydown', 'onkeypress', 'onkeyup', 'onclick', 'ondblclick', 'onchange'] , function(name) { f [name] = function(e) { var event = e || window.event;
          Hide
          Ted Goddard added a comment -

          Is the f.onsubmit = none necessary in some conditions?

          Show
          Ted Goddard added a comment - Is the f.onsubmit = none necessary in some conditions?
          Ted Goddard made changes -
          Assignee Ted Goddard [ ted.goddard ] Mircea Toma [ mircea.toma ]
          Hide
          Ted Goddard added a comment -

          Server code takes UINamingContainer.getSeparatorChar() into account, but client-side script does not. Perhaps this is available from the jsf.js API. If not, it should be.

          Show
          Ted Goddard added a comment - Server code takes UINamingContainer.getSeparatorChar() into account, but client-side script does not. Perhaps this is available from the jsf.js API. If not, it should be.
          Hide
          Mircea Toma added a comment - - edited

          Theoretically, it seems that 'f.onsubmit = none' is not necessary. There are certain events (within certain browsers) that are not canceling the default action even if they are told so. See 'click' event for example, 'Prevent Default' section: http://www.quirksmode.org/dom/events/click.html .
          Also, to avoid any browser specific issues the 'onsubmit' is disabled in case the 'submit' event is generated by the browser during capturing phase instead of bubbling phase. See: http://www.quirksmode.org/js/events_order.html .

          Show
          Mircea Toma added a comment - - edited Theoretically, it seems that 'f.onsubmit = none' is not necessary. There are certain events (within certain browsers) that are not canceling the default action even if they are told so. See 'click' event for example, 'Prevent Default' section: http://www.quirksmode.org/dom/events/click.html . Also, to avoid any browser specific issues the 'onsubmit' is disabled in case the 'submit' event is generated by the browser during capturing phase instead of bubbling phase. See: http://www.quirksmode.org/js/events_order.html .
          Mircea Toma made changes -
          Assignee Mircea Toma [ mircea.toma ] Ted Goddard [ ted.goddard ]
          Hide
          Ted Goddard added a comment -

          Can we reproduce a problem in a certain browser with that line commented out? It will make the f:ajax disabled more complex to implement (we will need to conditionally set f.onsubmit to none in both places).

          Show
          Ted Goddard added a comment - Can we reproduce a problem in a certain browser with that line commented out? It will make the f:ajax disabled more complex to implement (we will need to conditionally set f.onsubmit to none in both places).
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21831 Thu Jul 01 12:59:07 MDT 2010 ted.goddard clear disabled list after rendering (ICE-5651)
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/event/FormSubmit.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21832 Thu Jul 01 13:00:09 MDT 2010 ted.goddard detect single disabled element (ICE-5651)
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/javascript/application.js
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21833 Thu Jul 01 13:07:01 MDT 2010 ted.goddard reload button has ajax disabled (ICE-5651)
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/samples/basic/src/main/webapp/icefaces.xhtml
          Hide
          Ted Goddard added a comment -

          <f:ajax disabled="true"> has no effect in basic, but is verified working in auction.

          Show
          Ted Goddard added a comment - <f:ajax disabled="true"> has no effect in basic, but is verified working in auction.
          Hide
          Ted Goddard added a comment -

          commandLink is not currently functional: the "onclick" is being handled by the span contained within the commandLink, so is not found in the "disabled" list.

          Show
          Ted Goddard added a comment - commandLink is not currently functional: the "onclick" is being handled by the span contained within the commandLink, so is not found in the "disabled" list.
          Hide
          Joanne Bai added a comment -

          Verified successfully the reload button on the icefaces.jsf page using

          Glimmer revision 21833
          Servers: Tomcat 6.0.26, Glassfish v3 with Mojarra 2.0.2 jars
          Browsers: FF3.6, IE8

          Show
          Joanne Bai added a comment - Verified successfully the reload button on the icefaces.jsf page using Glimmer revision 21833 Servers: Tomcat 6.0.26, Glassfish v3 with Mojarra 2.0.2 jars Browsers: FF3.6, IE8
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21848 Tue Jul 06 09:21:38 MDT 2010 ted.goddard support for commandLink and disabled config omitted when not used (ICE-5651)
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/javascript/application.js
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/event/FormSubmit.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/javascript/submit.js
          Hide
          Ted Goddard added a comment -

          commandLink is now supported.

          Note that <f:ajax disabled="false"> will often have undesirable side effects – this will result in the JSF 2.0 Ajax defaults being applied (such as execute and render "this").

          Optimizations are possible beyond the current implementation: when detecting commandLink, all disabled elements are tested for the existence of hidden fields with that identical name and value. This could be restricted to commandLink elements only.

          Show
          Ted Goddard added a comment - commandLink is now supported. Note that <f:ajax disabled="false"> will often have undesirable side effects – this will result in the JSF 2.0 Ajax defaults being applied (such as execute and render "this"). Optimizations are possible beyond the current implementation: when detecting commandLink, all disabled elements are tested for the existence of hidden fields with that identical name and value. This could be restricted to commandLink elements only.
          Ted Goddard made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Ken Fyten made changes -
          Fix Version/s 2.0.0 [ 10230 ]
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Assignee Priority P1

            People

            • Assignee:
              Ted Goddard
              Reporter:
              Deryk Sinotte
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: