Javascript function is not getting called onclick of hx:commandExButton

2.7k views Asked by At

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.

2

There are 2 answers

0
BalusC On BEST ANSWER

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 the onclick attribute value correctly into account. As a test, you could try to get rid of it and use the standard JSF h: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.

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

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.