【问题标题】:Refresh Table Inside the JSF Fragment刷新 JSF 片段内的表
【发布时间】:2013-01-10 05:35:11
【问题描述】:

我知道这很简单,但我似乎无法让它工作我知道如何使用部分触发器,但由于某些未知原因,我似乎无法让它工作。好吧,我的问题是,我的 jsf 片段中有一个<af:table>(我使用任务流来创建这个片段),我想做的是在我的文本字段上使用 valuechangelistener 创建一个简单的搜索方法,这样表格就会搜索每个文本字段上发生的变化很好,问题是<af:table partialTrigger=":id of my textfield"> 似乎没有工作它保留表中的旧值它没有刷新或者你有任何解决此类问题的方法。为了清楚起见,我将发布一些代码。

JSF 片段页面:

<?xml version='1.0' encoding='UTF-8'?>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
                xmlns:f="http://java.sun.com/jsf/core">
  <af:panelStretchLayout id="psl1" inlineStyle="width: 900px;">
    <f:facet name="center">
      <af:panelGroupLayout layout="scroll" id="pgl3">
        <af:panelGridLayout id="pgl1">
          <af:gridRow marginTop="5px" marginBottom="5px" height="auto" id="gr1">
            <af:gridCell marginStart="10px" width="100px" id="gc1" halign="end" valign="middle">
              <af:outputLabel value="Search: " id="ol1" inlineStyle="color:Black; font-size:12px; font-weight:bold;"/>
            </af:gridCell>
            <af:gridCell marginStart="10px" width="250px" id="gc2" halign="start" valign="middle">
              <af:inputText label=" " valueChangeListener="#{personnelFragment.SearchRecords}" autoSubmit="true" columns="40" id="searchTxt"/>
            </af:gridCell>
            <af:gridCell marginStart="10px" width="100px" id="gc3" halign="end" valign="middle">
              <af:outputLabel value="Sort By: " id="ol2" inlineStyle="color:Black; font-size:12px; font-weight:bold;"/>
            </af:gridCell>
            <af:gridCell marginStart="10px" marginEnd="5px" width="25%" id="gc4">
              <af:selectOneChoice label=" " id="soc1">
                <af:selectItem label="Firstname" id="si1"/>
                <af:selectItem label="Middlename" id="si2"/>
                <af:selectItem label="Lastname" id="si3"/>
              </af:selectOneChoice>
            </af:gridCell>
          </af:gridRow>
        </af:panelGridLayout>


        <af:table width="700px" partialTriggers=":searchTxt" id="t1" value="#{personnelFragment.personnelInfoData}" var="PersonnelData"
        horizontalGridVisible="true" verticalGridVisible="true" inlineStyle="margin: 10px 0 10px 0;"
        rowSelection="single">
            <af:column headerText="Prefix" align="center" id="c4">
                <af:outputLabel value="#{PersonnelData.prefix}" id="ol6"
                                inlineStyle="color:Black; font-size:10px;"/>
            </af:column>

            <af:column headerText="Firstname" align="center" id="c1">
                <af:outputLabel value="#{PersonnelData.firstName}" id="ol3"
                                inlineStyle="color:Black; font-size:10px;"/>
            </af:column>

            <af:column headerText="Middlename" align="center" id="c2">
                <af:outputLabel value="#{PersonnelData.middleName}" id="ol4"
                                inlineStyle="color:Black; font-size:10px;"/>
            </af:column>

            <af:column headerText="Lastname" align="center" id="c3">
                <af:outputLabel value="#{PersonnelData.lastName}" id="ol5"
                                inlineStyle="color:Black; font-size:10px;"/>
            </af:column>

            <af:column headerText="Suffix" align="center" id="c5">
                <af:outputLabel value="#{PersonnelData.suffix}" id="ol7"
                                inlineStyle="color:Black; font-size:10px;"/>
            </af:column>

            <af:column headerText=" " align="center" id="c6">
                <af:commandImageLink id="cil1" icon="#{resource['images:check.png']}" actionListener="#{personnelFragment.SearchPersonnelInfo}" />
            </af:column>
        </af:table>

  </af:panelGroupLayout>
</f:facet>
<f:facet name="top"/>

我的 Bean(Value Change Listener),但我只粘贴重要的部分:

        calState = (OracleCallableStatement)con.prepareCall("{ call SEARCH_PERSONNELINFO(?, ?) }");
    calState.setObject(1, e.getNewValue());
    calState.registerOutParameter(2, OracleTypes.CURSOR);
    calState.execute();
    rs = (ResultSet)calState.getObject(2);
    while(rs.next()){
        PersonnelInfoData.add(new GetPersonnelData(rs.getInt(1), rs.getString(2), rs.getString(3),
                                rs.getString(4), rs.getString(5), rs.getString(6)));
        System.out.println(rs.getInt(1) +" "+ rs.getString(2));

    }
    calState.close();

我使用了存储过程,这段代码运行良好,正如您所见,我将示例结果打印到日志并且运行良好。我的问题只是刷新页面。

1)。仅当有&lt;af:form&gt; 标签时才会发生partialTrigger 吗?(因为jsf 片段不支持&lt;af:form&gt;) 2)我刚才搜索了一下,在一些论坛中,他们以编程方式创建触发器,例如AdfFacesContext.getCurrentInstance().addPartialTarget(Component);,您能向我解释一下这段代码的用途吗? 3) 如何刷新 jsf 片段中的表格?

非常感谢您的帮助和指导。

【问题讨论】:

  • 你没有使用RichFaces。您正在使用Oracle ADF。我修复了不正确的标记。
  • 感谢 baluc,抱歉回复晚了 :)

标签: jsf oracle-adf


【解决方案1】:

尝试手动刷新 backing bean 中的表,如下所示: AdfFacesContext.getCurrentInstance().addPartialTarget(t1);

【讨论】:

  • 好吧,我已经尝试过这段代码,但它不起作用。或者我的代码有错误 我在论坛上看到了这段代码,但我不明白我应该把它放在哪里?我应该将此代码放在 valuechangelistener 代码上吗?
【解决方案2】:

1) af:form 标签位于您放置片段/任务流的 jsp/jspx 页面中(您可以检查它)。 2) 与 partialTrigger 属性相同,但不是 ID,而是使用 bean 中定义的绑定。
3) 就像你说的,使用 partialTrigger="id of your component"。

由于您使用 bean 来显示数据,您可能需要检查迭代器上的缓存(检查绑定,选择迭代器,检查属性)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多