简体   繁体   English

hx:commandExButton的onclick不会调用Javascript函数

[英]Javascript function is not getting called onclick of hx:commandExButton

When I click on the hx:commandExButton the Javascript function should get called, but it is not getting called. 当我单击hx:commandExButton ,应该调用Javascript函数,但是没有调用它。 The Javascript function is as follows: Javascript函数如下:

function test() {
    alert('ss');
    return  "true";
}

The hx:commandButton is as follows: hx:commandButton如下:

<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. 任何建议都会有所帮助。

First step would be to check the generated HTML output to verify if it looks right. 第一步是检查生成的HTML输出,以验证它看起来是否正确。 It may for instance happen that the hx:commandExButton itself didn't take the onclick attribute value correctly into account. 例如,可能发生hx:commandExButton本身未正确考虑onclick属性值的情况。 As a test, you could try to get rid of it and use the standard JSF h:commandButton instead. 作为测试,您可以尝试摆脱它,而使用标准JSF h:commandButton

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. 进一步讲,我还想起了一个疯狂的<hx:scriptCollector>标记,当您希望将Javascript与IBM Faces Client组件结合使用时,应该使用该标记包装JSF代码。

Eg 例如

<hx:scriptCollector id="someid">
    <hx:form>
       <hx:commandExButton />
    </hx:form>
</hx:scriptCollector>

I don't know JSF, but it's immediately obvious that you have omitted a " after true, and also a > 我不知道JSF,但是很明显,您省略了“ true之后”和“

Are those ** supposed to be there? 那些**应该在那里吗? And writing method before a function is definitely not part of standard JavaScript. 在函数之前编写方法绝对不是标准JavaScript的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM