【问题标题】:Selection doesn't work in extendedDataTable, RichFaces 4 + JSF 2.0选择在extendedDataTable、RichFaces 4 + JSF 2.0 中不起作用
【发布时间】:2011-12-25 05:50:26
【问题描述】:

我有一个带有 RichFaces 4.0.0.Final 和 JSF 2.0 的应用程序。当我尝试在扩展数据表中使用选择时,它不起作用。

<rich:extendedDataTable
                    id="shipmentList" value="#{shipmentListBean.shipmentList}" var="shipment"
                    rowClasses="#{shipment.paymentDate == null ? 'unpaidShipment' : null}"
                    selectionMode="single" noDataLabel="#{msgs.emptyList}"                        
                    selection="#{shipmentListBean.selection}"
                    style="width: 1200px; font-size: 10px; ">

ShipmentListBean:

@ManagedBean
@ApplicationScoped
public class ShipmentListBean implements Serializable {

    private Collection<Object> selection = null;

    public ShipmentListBean() {
    }

    public List<ShipmentValueObject> getShipmentList() {
        ....
    }


    public Collection<Object> getSelection() {
        return selection;
    }

    public void setSelection(Collection<Object> selection) {
        this.selection = selection;
    }
}

当我在表格中选择行时,为什么在方法 selSelection(Collection selection) 中出现空集合?

【问题讨论】:

    标签: java jsf jsf-2 richfaces


    【解决方案1】:

    你可以像这样使用选择

    in ShipmentListBean 
    
    
    
      private SimpleSelection selection = new SimpleSelection();
    
        // now time to get a selected Row id from the extendedDataTable. 
        // this method you can call on any button after selecting the row from the extendedDataTable
        public void selectedRecord(){
                try{
                    Iterator<Object> iterator = getSelection().getKeys();
    
                    while(iterator.hasNext()){
                        // Here you will get all the selected roes id from the Data table
                        Object obj = iterator.next();
    
                        info("GET SELECTED ROWS ID ::::: " + obj.toString());
    
                    }
                }catch(Exception e){
                    e.printStackTrace();
                }   
            }
    

    【讨论】:

      猜你喜欢
      • 2011-07-23
      • 1970-01-01
      • 2014-09-05
      • 1970-01-01
      • 2014-01-30
      • 2011-08-10
      • 2011-06-06
      • 1970-01-01
      • 2012-09-04
      相关资源
      最近更新 更多