本文整理汇总了Java中javax.faces.model.ArrayDataModel类的典型用法代码示例。如果您正苦于以下问题:Java ArrayDataModel类的具体用法?Java ArrayDataModel怎么用?Java ArrayDataModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrayDataModel类属于javax.faces.model包,在下文中一共展示了ArrayDataModel类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toDataModel
import javax.faces.model.ArrayDataModel; //导入依赖的package包/类
/**
* Converts an instance into a DataModel.
* @param value Supported instances include java.util.List and
* arrays.
*/
public static DataModel toDataModel(Object value)
{
if (value instanceof DataModel)
{
return (DataModel) value;
}
if (value instanceof Object[])
{
return new ArrayDataModel((Object[]) value);
}
if (value == null)
{
return new ListDataModel(Collections.emptyList());
}
else if (value instanceof List)
return new ListDataModel((List) value);
return new ScalarDataModel(value);
}
示例2: getDataModel
import javax.faces.model.ArrayDataModel; //导入依赖的package包/类
public DataModel getDataModel() {
if (this.model == null) {
Object val = this.getValue();
if (val == null) {
this.model = EMPTY_MODEL;
} else if (val instanceof DataModel) {
// noinspection unchecked
this.model = (DataModel<Object>) val;
} else if (val instanceof List) {
// noinspection unchecked
this.model = new ListDataModel<Object>((List<Object>) val);
} else if (Object[].class.isAssignableFrom(val.getClass())) {
this.model = new ArrayDataModel<Object>((Object[]) val);
} else if (val instanceof ResultSet) {
this.model = new ResultSetDataModel((ResultSet) val);
} else {
this.model = new ScalarDataModel<Object>(val);
}
}
return this.model;
}
示例3: setPayments
import javax.faces.model.ArrayDataModel; //导入依赖的package包/类
private void setPayments(final IPayment[] aPayments) {
if (aPayments == null) {
this.paymentsDataModel = new ArrayDataModel<IPayment>(new Payment[0]);
} else {
this.paymentsDataModel =
new ArrayDataModel<IPayment>(Arrays.copyOf(aPayments, aPayments.length));
}
if ((null == this.paymentsDataModel) || (this.paymentsDataModel.getRowCount() <= 0)) {
throw new IllegalArgumentException("Schedule cannot be null");
}
}