How can we set the value of a bean variable through java script on load?
I have tried doing this by setting the value onLoad but it doesnt reflect untill the page is submitted.
Is there any way out?
By definition, the bean can't be changed until something is submitted. JSF beans are located in the server, not in the client. To cause the server to change any object inside itself, you have to submit a request to the server.
You can submit a "behind the scenes" request, however. That's what AJAX is all about.
An IDE is no substitute for an Intelligent Developer.