admin管理员组

文章数量:1327945

im trying to call a bean from a javascript, using a h:mandLink.

i have a mandLink

                <h:mandLink action="#{bean.go()}"
                    styleClass="simple-submit-button" id="uLink">
                    <f:param name="userId" value="#{param['userId']}" />
                </h:mandLink>

which calls my bean.

and want to call this mandLink 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:mandLink immediate="false" and instead of document.getElementById('uLink').click() i used document.getElementById('uLink').immediate=true;
  • usinng h:mandButton instead.
  • using document.getElementById('formId:uLink').click();

Has anyone an idea how i get this work?

im trying to call a bean from a javascript, using a h:mandLink.

i have a mandLink

                <h:mandLink action="#{bean.go()}"
                    styleClass="simple-submit-button" id="uLink">
                    <f:param name="userId" value="#{param['userId']}" />
                </h:mandLink>

which calls my bean.

and want to call this mandLink 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:mandLink immediate="false" and instead of document.getElementById('uLink').click() i used document.getElementById('uLink').immediate=true;
  • usinng h:mandButton instead.
  • using document.getElementById('formId:uLink').click();

Has anyone an idea how i get this work?

Share asked May 16, 2012 at 14:56 user1338413user1338413 2,5518 gold badges31 silver badges36 bronze badges 5
  • Show the resulting HTML. It's likely that the HTML id is not simply uLink. – Paul Grime Commented May 16, 2012 at 15:00
  • do view source and see 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(); – Daniel Commented May 16, 2012 at 15:05
  • you're righ the id is 'formId:uLink'(checked with firebug), so now i dont get the error anymore. but it still doesnt work. – user1338413 Commented May 16, 2012 at 15:14
  • 1 That's a different problem :) – BalusC Commented May 16, 2012 at 15:16
  • its not really a different problem. the question is still unsolved: why does the link not calling the action? Or is the script not calling the link? dont know how to find it out. already checked this link stackoverflow./questions/2118656/… any help is appreciated. – user1338413 Commented May 18, 2012 at 7:54
Add a ment  | 

1 Answer 1

Reset to default 5

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(); 

本文标签: jsfCall commandlink action from JavascriptStack Overflow