0

嗨,我们与 a4j 标签一起使用。

在这里,我们在单击按钮后从数据库中检索数据。即使数据在服务器中可用,它也不会显示在视图中。手动刷新网页后会出现数据显示。

这是代码片段....这里有一些代码

  <rich:tab id="menu5" label="Recall">
  <ui:include src="/pages/mctrans/reCallMcifTrans.xhtml" />  
  </rich:tab>

reCallMcifTrans.xhtml 包含以下代码

<h:commandButton type="button" id="reCallbutton1" value="   Search   "
    styleClass="commandExButton">
    <a4j:support event="onclick" id="ajsf12"
        oncomplete="javascript:alert('Search   Completed');javascript:document.body.style.cursor='default';"
        action="#{mcifRecallTransBean.reCallSearch}" reRender="reCallgrid1" />
</h:commandButton>
4

2 回答 2

1

看起来您正在使用 RichFaces 3.3。因此,您不需要<h:commandButtonwith,<a4j:support>因为您可以使用<a4j:commandButton>它已经做到了这一点。您可以将代码重构为:

<a4j:commandButton type="button" id="reCallbutton1" value="Search"
    styleClass="commandExButton"
    action="#{mcifRecallTransBean.reCallSearch}"
    reRender="reCallgrid1"
    oncomplete="javascript:alert('Search   Completed');javascript:document.body.style.cursor='default';" />

确保您的reCallgrid1组件<h:form><a4j:commandButton>.

由于您还想在单击按钮时搜索数据行为时添加等待,您可以与演示中所示的<a4j:status>一起使用。这是一个基本示例:<a4j:commandButton><a4j:status>

<a4j:commandButton type="button" id="reCallbutton1" value="Search"
    styleClass="commandExButton"
    action="#{mcifRecallTransBean.reCallSearch}"
    reRender="reCallgrid1" />
<!-- Note that there's no oncomplete in this case -->
<a4j:status for="reCallbutton1">
    <f:facet name="start">
        <h:graphicImage  value="/res/images/wait.gif"/>
    </f:facet>
</a4j:status>

最后但同样重要的是,您应该将托管 bean 切换到请求范围并使用强大<a4j:keepAlive>的 RichFaces 来模拟 JSF 2 @ViewScoped。您甚至可以在托管 bean 上以注释的形式使用它(无需额外配置):

@KeepAlive
public class McifRecallTransBean {
    //managed bean code here...
}
于 2013-03-13T14:58:30.617 回答
0

当您在 bean 中使用请求参数时,您需要使用您的操作再次传递它们:

<h:commandButton type="button" id="reCallbutton1" value="Search" styleClass="commandExButton">
    <a4j:support event="onclick" id="ajsf12" oncomplete="javascript:alert('Search  Completed');javascript:document.body.style.cursor='default';" action="#{mcifRecallTransBean.reCallSearch}" reRender="reCallgrid1" />
    <f:param name="param1" value="#{param['param1']}" />
    <f:param name="param2" value="#{param['param2']}" />
</h:commandButton>
于 2013-03-13T10:41:24.087 回答