Beim Verwenden von Primefaces werden <h:inputCommand> und native HTML-Buttons nicht im Primefaces-Style dargestellt. Folgendes JavaScript korrigiert dies:
function init() {
var inputs = document.getElementsByTagName("input");
for (var i = 0; i < inputs.length; ++i) {
var input = inputs[i];
if ((input.type === 'submit' || input.type === 'button') && typeof input.classNameBase == 'undefined') {
input.classNameBase = input.className +
" ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-button-text";
input.className = input.classNameBase;
input.addEventListener("mouseover", onmouseover, false);
input.addEventListener("mouseout", onmouseout, false);
}
}
}
function onmouseout(event) {
event.target.className = event.target.classNameBase;
}
function onmouseover(event) {
event.target.className = event.target.classNameBase + " ui-state-hover";
}
document.body.addEventListener("load", init, true);
function initAjax(data) {
if (data.status == 'success')
init();
}
jsf.ajax.addOnEvent(initAjax);