0

How do I use Javascript to "click" on a CommandButton?

I tried the following but it doesnt work:

<ice:panelTab id="searchResultsTab" label="Search Results" onclick="document.getElementById('form:searchTabs:0:refreshButton').click();">

Thanks.

1 Answer 1

2

Either the element ID is wrong, or the ice:panelTab itself is doing something during onclick as well which has overriden your onclick, or the HTML rendering went bogus (this can happen in one very specific situation) and the onclick attribute has never been rendered to the response.

To fix the first, doublecheck the page source. To fix the second, check the page source if that is indeed the case and then add a return false; to end of the onclick. To fix the third, you'll first need to confirm that the onclick is indeed not there in the HTML output and then tell more about JSF API and impl versions.

All with all, the answer is in the generated HTML output. It's also the running context of Javascript.

Sign up to request clarification or add additional context in comments.

2 Comments

Strange...I've double checked the ID but it doesnt seem to work...If I move the commandButton out of the panelTabSet and change the Id to form:refreshButton it does work...is this some AJAX issue? Cant see how to access it.
Sorry, since I don't do IceFaces, I can't tell from head how it is supposed to behave and generate HTML. Just check and debug the generated HTML/JS source. Firebug is very helpful here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.