<h:panelGrid columns="3">
<h:commandButton value="salut" actionListener="#{greetingController.saySalut}">
<f:ajax render="@form" event="click" />
</h:commandButton>
<!-- 上面这种写法是无法正常运行的。-->
<!-- f:ajax会异步获取message的当前值,但是h:commandButton的actionListener却没有机会执行。应该去掉f:ajax event="*" -->
<!-- 正解是下面这一段代码 -->
<h:commandButton value="hello" actionListener="#{greetingController.sayHello}">
<f:ajax render="message" />
</h:commandButton>
</h:panelGrid>
<h:panelGrid>
<h:outputText id="message" value="#{greetingController.message}" />
</h:panelGrid>
f:ajax 与 h:commandButton 使用备忘(真要好好看看书了)
最新推荐文章于 2021-08-06 13:56:47 发布