Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-1032

use a javascript method in commondLink for lesser html size

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.1.5
    • General
    • None

    Description

      The attached patch will introduce a new javascript method which will be used for the commandLink form submission handling.

      The name of this new javascript method is "myfcs_sbmt" and will be rendered once (on first use) into the html.
      It allows to pass in 4 parameters:
      frm - form name
      srcElement - the element issuing the onclick - the anchor tag in the current case
      target - the target (not strictly necessary for the anchor, but useable for the future (commandButton) )
      prms - a javascript hash array for the components f:params
      See the resulting javascript below.

      The resulting href-onclick tag will be
      <a href="#" onclick="clear_navigation_3Atest();return myfcs_sbmt('navigation:test',this,'',

      {'p1':'pv1','p2':'pv2'}

      )" id="navigation:test:_idJsp31">params</a>

      Next thing to do will be to get rid of the clear_() method, but one after the other.

      It would be REALLY GREAT if one of you developers can have a look at this (for sure) rather large patch. If you are happy it would be even MORE GREAT if you could apply it so that I can see how it works in wild life.
      If everything is fine I will have a look how to get rid of the clear_ methods and move on to the commandButton. There is not much to win, but a little bit is better than nothing
      Especially it would be nice if both use the same (centralized) methods to render their onClick things.

      The new javascript (rendered without any newline in reality)

      function myfcs_sbmt(frm,srcElem,target,prms)
      {
      var formElement = document.forms[frm];
      document.forms[frm].elements['autoScroll'].value=getScrolling();
      formElement.elements[frm+':_link_hidden_'].value=srcElem.id;

      if (target != '')

      { formElement.target=target; }

      for (var paramName in prms)

      { formElement.elements[paramName].value=prms[paramName]; }

      if(formElement.onsubmit)
      {
      var result=formElement.onsubmit();
      if( (typeof result == 'undefined') || result )

      { formElement.submit(); }

      }
      else

      { formElement.submit(); }

      return false;
      }

      Attachments

        1. onclick_method.diff
          15 kB
          Mario Ivankovits

        Activity

          People

            mmarinschek Martin Marinschek
            imario Mario Ivankovits
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: