我有一个豆子:
@ManagedBean
@SessionScoped
public class MainTable
{
static List<MainTableRow> rows;
public MainTable()
{
rows = new ArrayList<>();
}
public static boolean addRow(MainTableRow mainTableRow)
{
return rows.add(mainTableRow);
}
public List<MainTableRow> getRows()
{
return rows;
}
public void setRows(List<MainTableRow> rows)
{
MainTable.rows = rows;
}
}
我的 xhtml 页面是:
<h:body>
<h3>Query Modeling Tool - Select Excel file</h3>
<h:form>
<p:fileUpload
fileUploadListener="#{fileUploadController.handleFileUpload}"
mode="advanced" dragDropSupport="false" update="messages"
sizeLimit="10000000" fileLimit="3" allowTypes="/(\.|\/)(xls)$/"
style="font-size: 14px" />
<p:growl id="messages" showDetail="true" />
<p:dataTable id="dataTable" var="mainTableRow"
value="#{mainTable.rows}" style="font-size: 14px">
<f:facet name="header">Main Table</f:facet>
<p:column sortBy="" headerText="Index">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Query">
<h:outputText value="#{mainTableRow.query}" />
</p:column>
<p:column sortBy="" headerText="S1">
<h:outputText value="#{mainTableRow.s1}" />
</p:column>
<p:column sortBy="" headerText="S2">
<h:outputText value="#{mainTableRow.s2}" />
</p:column>
<p:column sortBy="" headerText="S3">
<h:outputText value="#{mainTableRow.s3}" />
</p:column>
<p:column sortBy="" headerText="S9">
<h:outputText value="#{mainTableRow.s9}" />
</p:column>
<p:column sortBy="" headerText="Uygunluk">
<h:outputText value="#{mainTableRow.uygunluk}" />
</p:column>
<p:column sortBy="" headerText="Kural">
<h:outputText value="#{mainTableRow.kural}" />
</p:column>
<p:column sortBy="" headerText="Kaynak">
<h:outputText value="#{mainTableRow.kaynak}" />
</p:column>
<p:column sortBy="" headerText="Query Type">
<h:outputText value="#{mainTableRow.queryType}" />
</p:column>
<p:column sortBy="" headerText="User Intent">
<h:outputText value="#{mainTableRow.userIntent}" />
</p:column>
</p:dataTable>
</h:form>
</h:body>
上传文件后,MainTable 中的“行”由另一个类填充。上传后我想刷新数据表而不点击任何按钮。我该怎么做?