Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-1593

Add s:jsCallbackFunction and s:jsOnEventAjax tags

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • JSF2
    • None

    Description

      Trying to do some stuff with JSF and javascript, I notice there is no tag that can generate javascript functions inline.

      This is different that a typical script block, when you put something that will be executed as soon as the page is loaded. In this case, the function will be used later by effect of a client behavior like f:ajax or s:effectXXX.

      Usually as best practice, you put all javascript code in one place, but in javascript it is common to use callbacks. For example, you want to execute some javascript after an ajax operation. So you create a js function and then put the function name on f:ajax onevent property, but you find quickly this does not work with composite components that are used many times on the same page because the script is rendered multiple times and the function is overriden over and over. In cases like that you want an unique name based on a clientId, so each time the component is rendered at different locations, a different name is used.

      s:jsCallbackFunction generate this content:

      generatedFunctionNameUsingClientIdAndEventName = function (... arguments ...)

      { ... jsStartContent ... ... clientBehavior scripts ... ... jsEndContent ... }

      and s:onEventAjax is similar to s:jsCallbackFunction, but specialized to prevent write more javascript than necessary. It generated this content:

      generatedFunctionNameUsingClientIdAndEventName = function (... arguments ...){
      ... jsStartContent ...
      if(e.status == '...')

      { ... jsBeforeClientBehaviors ... ... clientBehavior scripts ... ... jsAfterClientBehaviors ... }

      ... jsEndContent ...
      }

      Attachments

        Activity

          People

            lu4242 Leonardo Uribe
            lu4242 Leonardo Uribe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: