2013-01-10 92 views
0

我知道這很簡單,但我似乎無法得到它的工作我知道如何使用部分觸發器,但由於某些未知的原因,我似乎無法使其工作。那麼我的問題是,我有一個<af:table>我的jsf片段(我用任務流創建此片段),我想要做的是創建一個簡單的搜索方法,在我的文本字段上使用valuechangelistener,所以表將搜索每一個變化發生在textfield上的問題是<af:table partialTrigger=":id of my textfield">似乎無法正常工作,它保留了表格中的舊值,它不會令人耳目一新,或者您有任何解決此類問題的方法。爲了說清楚,我會發布一些我的代碼。刷新表內JSF片段

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"/> 

我的豆(價值變化監聽),但我只是粘貼重要的部分:

 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)。部分觸發器只會發生如果有<af:form>標籤?(因爲jsf片段不支持<af:form>) 2)我搜索了一段時間,並在一些論壇,他們創建觸發器編程這樣的AdfFacesContext.getCurrentInstance().addPartialTarget(Component);你能請你解釋一下這段代碼的用途是什麼? 3)如何在jsf片段中刷新我的表格?

幫助和指導將非常感激。

+0

你沒有使用[RichFaces](http://jboss.org/richfaces)。您正在使用[Oracle ADF](http://www.oracle.com/technetwork/developer-tools/adf/overview/index.html)。我修正了錯誤的標籤。 – BalusC

+0

感謝baluc,對於回覆晚了感到抱歉:) –

回答

0

嘗試使用以下一行手動刷新後臺Bean中的表: AdfFacesContext.getCurrentInstance()。addPartialTarget(t1);

+0

嗯,我已經試過這段代碼,它不工作。或者也許我在我的代碼上有一個錯誤我在論壇上看到這個代碼,但我不明白我在哪裏放它?我應該將這些代碼放在valuechangelistener代碼中嗎? –

0

1)af:form標籤位於jsp/jspx頁面,您丟棄了您的fragment/taskflow(您可以檢查它)。 2)與partialTrigger屬性相同,但是使用在bean中定義的綁定而不是ID。
3)像你說的,使用partialTrigger =「你的組件的ID」。由於您使用的是bean來顯示數據,因此您可能需要檢查迭代器上的緩存(檢查綁定,選擇迭代器,檢查屬性)。

+0

試試這個。謝謝。 –