How does the rendered thing solved the problem? Can someone explain the details on this?
Just wondering if there is any way without calling <onload="test()">, to solve this requirement.
Can anyone give a pointer on this? Thanks.

The hidden button does not work beause the action handler answers with a page, which is the same page in this case. So the page will get re-loaded and because the onload script clicks the button again, the page gets reloaded in an endless loop.

Sometimes the solution is so easy to oversee it:

This calls the init method when the page gets loaded.

If you use the older JSF 1.2 release, then write #{myBean.init} and name the method getInit().

Stefan Frings wrote:The hidden button does not work beause the action handler answers with a page, which is the same page in this case. So the page will get re-loaded and because the onload script clicks the button again, the page gets reloaded in an endless loop.

Sometimes the solution is so easy to oversee it:

This calls the init method when the page gets loaded.

If you use the older JSF 1.2 release, then write #{myBean.init} and name the method getInit().

I could not get this solution to work in my case. I created a web page where the submit button executes myBean.method. I need to eventually remove the Submit button and for myBean.method to be executed when the page is loaded. Here is the code for the submit button

Stefan Frings wrote:The hidden button does not work beause the action handler answers with a page, which is the same page in this case. So the page will get re-loaded and because the onload script clicks the button again, the page gets reloaded in an endless loop.

Sometimes the solution is so easy to oversee it:

This calls the init method when the page gets loaded.

If you use the older JSF 1.2 release, then write #{myBean.init} and name the method getInit().

***

I was able to get the above post to work but I ended up putting the call in between the <head> tags and modifying it slightly.
Section of my index.xhtml

Method in my Managed Bean Controller msbController.java

Notice the addition of parenthesis after the init method name.
Works like a champ thanks Stefan!

Also, some people may do fine just adding the code they want to execute on page load in the managed bean controller's constructor method.

What you have done is what we call "awakening a zombie" - posting to a thread that has been dormant for so long that most of the people involved have probably moved on to other projects and often other employers. We'd prefer that you simply start a new thread rather than do this, as it's less confusing.

BTW. JSF backing beans are not Controllers, they are Models.

Customer surveys are for companies who didn't pay proper attention to begin with.