Call commandlink action from Javascript

jakarta-ee, javascript, jsf

Solution

do `view source` in you browser and look on the exact the id of the button , it might look like `someContainerID:uLink` or `someFormID:uLink` and not just `uLink` so you might need to use

document.getElementById('someFormID:uLink').click(); 

OR

document.getElementById('someContainerID:uLink').click(); 

Problem

im trying to call a bean from a javascript, using a h:commandLink. i have a commandLink ``` <h:commandLink action="#{bean.go()}" styleClass="simple-submit-button" id="uLink"> <f:param name="userId" value="#{param['userId']}" /> </h:commandLink> ``` which calls my bean. and want to call this commandLink from javascript, like this: ``` document.getElementById('uLink').click(); ``` but i m always getting the error: document.getElementById('uLink') is null. I tried this: - setting h:commandLink immediate="false" and instead of document.getElementById('uLink').click() i used document.getElementById('uLink').immediate=true; - usinng h:commandButton instead. - using document.getElementById('formId:uLink').click(); Has anyone an idea how i get this work?

Original source

Related problems