0

我知道这很简单,但我似乎无法让它工作我知道如何使用部分触发器,但由于某些未知原因,我似乎无法让它工作。好吧,我的问题是<af:table>,我的 jsf 片段内部有一个(我使用任务流来创建这个片段),我想做的是在我的文本字段上使用 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(值更改侦听器),但我将粘贴重要部分:

        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)。partialTrigger 只有在有标签的情况下才会发生<af:form>吗?(因为 jsf 片段不支持<af:form>)2)我刚刚搜索过,在一些论坛中,他们像这样以编程方式创建触发器AdfFacesContext.getCurrentInstance().addPartialTarget(Component);,你能解释一下这段代码是什么吗为了?3) 如何刷新 jsf 片段中的表格?

帮助和指导将不胜感激。

4

2 回答 2

0

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

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

于 2013-01-11T08:45:35.770 回答
0

尝试使用以下行手动刷新支持 bean 中的表:AdfFacesContext.getCurrentInstance().addPartialTarget(t1);

于 2013-01-10T18:56:51.607 回答