【问题标题】:JSF: Datatable is not updatingJSF:数据表未更新
【发布时间】:2016-05-09 07:54:24
【问题描述】:

我正在学习 JSF 并遇到以下问题:

Xhtml 类:

    <h:form><p:inputText  value="#{tempView.tempName}" e:placeholder="Search Name">
    </p:inputText>
    <p:commandButton id="search" value="Search" action="#{tempView.searchName()}" update="dataTable">
    </p:commandButton>
    <p:commandButton value="clear" action="#{tempView.clearSearchCriteria()}" update="dataTable">
    </p:commandButton>


<p:dataTable id="dataTable"
    value="#{tempView.tmpList}"
    var="tempVar" rowStyleClass="#{tempView.rowStyleClass(tempVar)}"
    rows="12" paginator="true"
    paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink}
    {LastPageLink} {RowsPerPageDropdown}"
    rowsPerPageTemplate="5,10,15" scrollable="true">

    <p:column headerText="First Name" sortBy="#{tempVar.firstName}">
        <h:outputText value="#{tempVar.firstName}" />
    </p:column>

    <p:column headerText="Last Name" sortBy="#{tempVar.lastName}">
        <h:outputText value="#{tempVar.lastName}" />
    </p:column>

    <p:column headerText="Institute / Practice Name" sortBy="#{tempVar.Address}">
        <h:outputText value="#{tempVar.instituteName}" />
    </p:column>
</p:dataTable>

Java 类:

public String searchName() {

    System.out.println("Executed");


    /**

        logic of refining list..
    **/

}

我面临的问题是..首先它是调用 getter 和 setter 方法,然后是 action 'searchName',然后是执行 action 方法。由于我的数据表没有更新,它没有调用 getter 和 setter。 操作方法“searchName”具有细化数据表中列表的逻辑。 如果您需要任何其他信息,请告诉我。 谢谢。

【问题讨论】:

  • 你的意思是调用searchName方法时你的datatable中的数据没有更新吗?
  • Hamaza:是的,数据没有更新:/
  • 你能显示更多你的数据表和searchName方法代码吗?
  • 请添加更多代码。你有表单标签吗?
  • 控制台是否有任何错误?

标签: jsf jsf-2 primefaces datatable


【解决方案1】:

不要使用 Action ,而是使用 ActionListener。您需要更改 bean 中的方法以返回 void 并添加 ActionEvent 作为参数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多