tags:

views:

204

answers:

2

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.

A: 

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.

eBusiness
I've edited his post, but I don't think this is his problem, otherwise the button would not even be displayed in his page...
romaintaz
+3  A: 

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>
BalusC