1 Reply Latest reply on Feb 22, 2010 3:24 AM by Michael Abele

    how indicate initial focus

    michaelklem Newbie

      Hello,

       

      RichFaces newbie here. I have been trying to figure out how I can specify that a text field on a RichFaces/JSf page is to get the initial focus. I have not been able to find any documentation on this.

       

      Thanks

        • 1. Re: how indicate initial focus
          Michael Abele Newbie

          Hey,

           

          we use a non-RichFaces solution using onload attribute of <body> tag.

           

          <body onload="go('main:idToFocus')">

           

          function  go(id) {
               document.getElementById(id).focus();
          }


          If you are using Facelets and only have a general <body> Tag in your page template, use a onload Function in template like

           

          <body onload="onloadFunction();">

           

          and override this function in your page

           

          function onloadFunction() {
               document.getElementById('main:idToFocus').focus();
          }

           

          Hope that helps!

           

          Regards,

          Michael