2012-01-08 5 views
1

私はrich:dataTable列の中のrich:selectコンポーネントを持っています。 a4j:ajaxタグを追加して、onblurイベントを処理し、この選択された行に関連するいくつかの値を処理しました。JSF DataModel getRowDataは常に最初の行(インデックスがゼロ)を返します

しかし、これはデータテーブルの最初の行に対してのみ有効で、2行目では最初の行と同じになります。

コードをトレースしたとき、datamodel.getRowData()メソッドが常に最初の行を返すことがわかりました。 また、datamodel.getRowCount()が正しい行数を返すことがわかりました。 しかし、datamodel.getRowIndex()は常にゼロを返します。

ANYヘルプ???

ここに私のManagedBeanコード(必要なコードのみ)である* *

@ManagedBean(name = "saleBacking") 
@SessionScoped 
public class SaleBacking implements Serializable{ 


private DataModel<SaleLine> model ; 
    public DataModel<SaleLine> getModel() { 
     if (model == null) { 
      model = new ListDataModel<SaleLine>(salesLines); 
     } 
     return model; 
    } 

    public void updateRowData(AjaxBehaviorEvent event) 
    { 
     currentSaleLine = (SaleLine)getModel().getRowData(); 
     System.out.println("Row count= "+getModel().getRowCount() + " , Row index= " + getModel().getRowIndex()) ;// this always return the correct rowCount but the index equal Zero (the first row of the datamodel) 
     if(currentSaleLine.getItemId() != null && currentSaleLine != null) 
     { 
      currentSaleLine.setItemPrice(currentSaleLine.getItemId().getItemDefEndUserPrice()); 
      currentSaleLine.setPl(currentSaleLine.getItemId().getItemDefEndUserPrice()); 
      currentSaleLine.setQuantity(1d); 
      currentSaleLine.setNetValue(currentSaleLine.getItemPrice() * currentSaleLine.getQuantity()) ; 
      calculateTotalSale(); 
     } 
    } 
} 

Sale.xhtml

<rich:dataTable value="#{saleBacking.salesLines}" var="line" rows="50" id="datatable">         
    <rich:column> 
               <f:facet name="header"><h:outputLabel value="#{msgs.item}" style="font-size:15px;"/></f:facet> 
     <rich:select enableManualInput="true" 
        value="#{line.itemId}" 
        clientFilterFunction="containsFilter" 
        converter="#{itemConverter}" 
        defaultLabel="please write the item name" onlistshow="alert('jhjhj');" 
        > 
      <f:selectItems value="#{saleBacking.items}" var="item" itemValue="#{item}" itemLabel="#{item.code} #{item.name}"/> 
      <a4j:ajax event="blur" execute="@this" listener="#{saleBacking.updateRowData}" render="datatable master2" oncomplete="document.getElementById('myform:datatable:#{line.viewNo-1}:price').focus();"/> 
     </rich:select> 
    </rich:column> 
</rich:dataTable> 
+1

私はこの構造を使っていないので、わかりません。しかし、 'SaleLine currentSaleLine = context.getApplication()。evaluateExpressionGet(context、"#{line} "、SaleLine.class);'が現在の行を返すかどうかを確認してみてください。 – BalusC

+0

それは働いた!!!!ありがとう、たくさんの男。 –

答えて

0

私は前にこの構文を使用していません、私は確信していません。しかし、SaleLineを試してみてくださいcurrentSaleLine = context.getApplication()。evaluateExpressionGet(context、 "#{line}"、SaleLine.class);現在の行が返されるかどうかをチェックします。 - @BalusC昨日

関連する問題