0

I´m trying to do that with DOM:

        <script type="text/javascript">
            document.addEventListener('DOMContentLoaded', function() {
                document.getElementById('frmTotem:undCGC').focus();
            });
        </script>

Where "undCGC" is an input secret from richfaces -> h:inputSecret.

But focus() or select() functions do not work properly. Any cue will be very welcome. Thanks!

Ito
  • 2,167
  • 3
  • 23
  • 32
  • we had this question (and answer) in the past... please checkout: http://stackoverflow.com/questions/1591910/how-to-focus-on-a-form-input-text-field-on-page-load-using-jquery – Ido Green Dec 20 '11 at 13:49

2 Answers2

0

Ito ,

I also face same issue in past,

I just say its your some property issue for <h:inputSecret> tag .

checkout this link http://myfaces.apache.org , here you can see when focus works or not for inputSecret. search "focus" in page and you will get all condition where its work or not.

Let me know if not works,next time provide your code

Jubin Patel
  • 1,959
  • 19
  • 38
0

Simply, the following?

document.getElementById('undCGC').focus();
Joop Eggen
  • 107,315
  • 7
  • 83
  • 138
  • Thanks but didn´t work! My ID is the same informed, but the code does not focus the element. – Ito Dec 20 '11 at 14:56
  • Then it is probable that the presence of the DOM still does not mean that everything is rendered. See http://mkblog.exadel.com/2009/12/richfaces-built-in-client-functions/, and maybe http://www.webreference.com/programming/javascript/onloads/index.html – Joop Eggen Dec 20 '11 at 15:58
  • Thanks Joop, I will check it out. – Ito Dec 20 '11 at 17:06