我有丰富的:选择一个丰富的内部组件:dataTable的列。 我说A4J:AJAX标签来处理onblur事件,处理与此相关的选定行的某些值
。但这个工作唯一正确的数据表中的第一行,第二行是做同样的第一行的
当我跟踪我的code我发现datamodel.getRowData()方法返回的第一行始终。 此外,我发现datamodel.getRowCount()返回正确的行数。 但datamodel.getRowIndex()返回零始终。
任何帮助???
的下面是我ManagedBean code(所需的code只)的 * 的*
@ManagedBean(NAME =saleBacking)
@SessionScoped
公共类SaleBacking实现Serializable {
私人的DataModel< SaleLine>模型 ;
公众的DataModel< SaleLine> getModel(){
如果(型号== NULL){
模型=新ListDataModel业务< SaleLine>(salesLines);
}
回归模型;
}
公共无效updateRowData(AjaxBehaviorEvent事件)
{
currentSaleLine =(SaleLine)getModel()getRowData()。
的System.out.println(行数=+ getModel()getRowCount()+,行的索引=+ getModel()getRowIndex()); //这总是返回正确的rowCount等,但该指数等于零(数据模型中的第一行)
如果(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
<丰富:dataTable的值=#{saleBacking.salesLines}VAR =行行=50ID =数据表>
<丰富:列>
< F:面名=标头>< H:outputLabel值=#{msgs.item}的风格=字体大小:15px的;/>< / F:面>
<丰富:选择enableManualInput =真
值=#{line.itemId}
clientFilterFunction =containsFilter
转换器=#{itemConverter}
defaultLabel =请写出项目名称onlistshow =警报('jhjhj');
>
< F:selectItems的值=#{saleBacking.items}VAR =项itemValue =#{}项itemLabel =#{项目code}#{item.name}/>
< A4J:AJAX事件=模糊执行=@这个监听器=#{saleBacking.updateRowData}渲染=数据表master2的onComplete =的document.getElementById('MyForm的:数据表:#{line.viewNo- 1}:价格)专注();/>
< /富:选择>
< /富:列>
< /富:dataTable的>
解决方案
我还没有使用这个结构之前,所以我不知道。但尝试SaleLine currentSaleLine = context.getApplication()evaluateEx pressionGet(背景下,#{}行,SaleLine.class)。检查它是否返回当前行。 - @BalusC昨天
I have rich:select component inside a rich:dataTable column. I added a4j:ajax tag to handle onblur event , to process some values related to this selected row.
But this worked only correct for the first row of the datatable , in the second row it do the same as in the first row.
When I traced my code I found that the datamodel.getRowData() method return the first row always. Also I found that the datamodel.getRowCount() return the correct number of rows. BUT datamodel.getRowIndex() return ZERO always.
ANY help ???
Here is my ManagedBean code (the needed code only) **
@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>
解决方案
I haven't used this construct before, so I'm not sure. But try SaleLine currentSaleLine = context.getApplication().evaluateExpressionGet(context, "#{line}", SaleLine.class); to check if it returns the current row. – @BalusC yesterday