本文整理匯總了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");
}
}