Javascript 函数没有被调用 hx:commandExButton 的 onclick
当我点击 hx:commandExButton
时,Javascript 函数应该被调用,但它没有被调用。 Javascript 函数如下:
function test() {
alert('ss');
return "true";
}
hx:commandButton
如下:
<hx:commandExButton
type="submit"
value="Search"
styleClass="action2" id="searchButton"
onclick="return test();"
action="#{pc_WorkInProgressUserGrid.doSearchButtonAction}"
immediate="true">
</hx:commandExButton>
任何建议都会有所帮助。
When I click on the hx:commandExButton
the Javascript function should get called, but it is not getting called. The Javascript function is as follows:
function test() {
alert('ss');
return "true";
}
The hx:commandButton
is as follows:
<hx:commandExButton
type="submit"
value="Search"
styleClass="action2" id="searchButton"
onclick="return test();"
action="#{pc_WorkInProgressUserGrid.doSearchButtonAction}"
immediate="true">
</hx:commandExButton>
Any suggestion would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一步是检查生成的 HTML 输出以验证其看起来是否正确。例如,
hx:commandExButton
本身可能没有正确考虑onclick
属性值。作为测试,您可以尝试摆脱它并使用标准 JSFh:commandButton
代替。此外,我还记得一些关于疯狂的
标记的事情,每当您想要将 Javascript 与 IBM Faces Client 组件结合使用时,您都应该用它来包装 JSF 代码片段。例如
First step would be to check the generated HTML output to verify if it looks right. It may for instance happen that the
hx:commandExButton
itself didn't take theonclick
attribute value correctly into account. As a test, you could try to get rid of it and use the standard JSFh:commandButton
instead.Further I also recall something about a crazy
<hx:scriptCollector>
tag which you are supposed to wrap the piece of JSF code with whenever you'd like to use Javascript in combination with IBM Faces Client components.E.g.
我不知道 JSF,但很明显你在 true 之后省略了一个 ",还有一个 >
这些 ** 应该在那里吗?在函数之前编写方法绝对不是标准 JavaScript 的一部分。
I don't know JSF, but it's immediately obvious that you have omitted a " after true, and also a >
Are those ** supposed to be there? And writing method before a function is definitely not part of standard JavaScript.