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
1 Answer
Reset to default 5do 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
版权声明:本文标题:jsf - Call commandlink action from Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742221346a2435461.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论