【发布时间】:2011-09-22 06:08:09
【问题描述】:
我希望以下表单使用 AJAX。因此,在单击命令按钮后会显示 cmets,而无需重新加载页面。使用 Java Server Faces 2.0 需要更改哪些内容?
功能:这个表单提供了一个 inputText 来定义一个主题。按下 commandButton 后,将搜索有关此主题的 cmets。注释显示在数据表中(如果有)。否则显示空。
<h:form id="myForm">
<h:outputLabel value="Topic:" for="topic" />
<h:inputText id="topic" value="#{commentManager.topic}" />
<h:commandButton value="read" action="#{commentManager.findByTopic}" />
<h:panelGroup rendered="#{empty commentManager.comments}">
<h:outputText value="Empty" />
</h:panelGroup>
<h:dataTable
id="comments"
value="#{commentManager.comments}"
var="comment"
rendered="#{not empty commentManager.comments}"
>
<h:column>
<h:outputText value="#{comment.content}"/>
</h:column>
</h:dataTable>
</h:form>
【问题讨论】: