我有一个提交 ajax 请求的按钮:
<h:commandButton>
<f:ajax listener="..." onevent=".." onerror="" render="panel1" />
</h:commandButton>
<h:panelGrid id="panel1" styleClass="${bean.style}> ....
如果 ajax 成功,我可以通过更改 bean.style 来更改 CSS,但我也想更改 ajax 发送时间和 ajax 失败时间。例如,我想将样式更改为.panel-inprogress
用户单击按钮.panel-failed
时失败时的样式。
我知道我可以在 JavaScript 中做到这一点,例如在我的代码中的 onevent 和 onerror 属性中,但我想知道是否有一种“JSF”方式来做到这一点。