javax.faces.model.DataModel Java Examples
The following examples show how to use
javax.faces.model.DataModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TabRepeat.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
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; }
Example #2
Source File: MovieController.java From tomee with Apache License 2.0 | 6 votes |
public PaginationHelper getPagination() { if (pagination == null) { pagination = new PaginationHelper(10) { @Override public int getItemsCount() { return getFacade().count(); } @Override public DataModel createPageDataModel() { return new ListDataModel(getFacade().findRange(new int[]{getPageFirstItem(), getPageFirstItem() + getPageSize()})); } }; } return pagination; }
Example #3
Source File: DataViewRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
protected void writeTableRowTagAttributes(FacesContext context, ResponseWriter w, AbstractDataView c, ViewDefinition viewDef) throws IOException { DataModel dm = viewDef.dataModel; String styleClass = c.getRowStyleClass(); if(StringUtil.isEmpty(styleClass)) { styleClass = (String)getProperty(PROP_TABLEROWCLASS); } if(dm.getRowIndex()==viewDef.first) { styleClass = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_TABLEFIRSTROWCLASS),styleClass); } if(dm.getRowIndex()==(viewDef.first+viewDef.rows-1)) { styleClass = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_TABLELASTROWCLASS),styleClass); } if(StringUtil.isNotEmpty(styleClass)) { w.writeAttribute("class", styleClass, null); // $NON-NLS-1$ } String style = c.getRowStyle(); if(StringUtil.isNotEmpty(style)) { w.writeAttribute("style", style, null); // $NON-NLS-1$ } }
Example #4
Source File: PagerAddRowsRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
protected boolean isDisabled(FacesContext context, ResponseWriter w, UIPagerAddRows pager, FacesDataIterator dataIterator) { DataModel dm = dataIterator.getDataModel(); int first = dataIterator.getFirst(); int rows = dataIterator.getRows(); int rc = dm.getRowCount(); if(rc<=first+rows) { if(dm instanceof TabularDataModel) { TabularDataModel tm = (TabularDataModel)dm; if(tm.canHaveMoreRows()) { int mr = first+rows+1; if(tm.hasMoreRows(mr)>=mr) { return false; } } } return true; } return false; }
Example #5
Source File: ForumViewRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
@Override protected void beforeRow(FacesContext context, ResponseWriter w, AbstractDataView c, ViewDefinition viewDef) throws IOException { super.beforeRow(context, w, c, viewDef); // In case of the first row, we generate the first indentation if(!viewDef.singleRowRefresh) { DataModel dm = viewDef.dataModel; if(dm.getRowIndex()==viewDef.first) { //int indent = (dm instanceof TabularDataModel) ? ((TabularDataModel)dm).getIndentLevel() : 0; int initialLevel = getColumnIndentLevel(context, c, viewDef); if(initialLevel>0) { startFirstRow(context, w, c, viewDef, initialLevel); viewDef.initialIndentLevel = initialLevel; } } } }
Example #6
Source File: QuestionPoolDataModel.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Creates a new QuestionPoolDatModel object. */ public QuestionPoolDataModel(Tree tree, DataModel model) { this.model = model; this.tree=tree; //buildTree(); }
Example #7
Source File: DataSourceIteratorRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected boolean isColumnSortable(FacesContext context, UIDataSourceIterator c, ViewDefinition viewDef, String columnName) { DataModel dm = viewDef.dataModel; if(dm instanceof TabularDataModel) { TabularDataModel tbm = (TabularDataModel)dm; return tbm.isColumnSortable(columnName); } return false; }
Example #8
Source File: RepeatTreeNode.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public ITreeNode.NodeIterator iterateChildren(int start, int count) { List<ITreeNode> children = getChildren(); if(children!=null && !children.isEmpty()) { DataModel dm = createDataModel(FacesContext.getCurrentInstance()); if(dm!=null) { return new RepeatIterator(dm,children.toArray(new ITreeNode[children.size()]),start,count); } } return null; }
Example #9
Source File: RepeatTreeNode.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public RepeatIterator(DataModel dataModel, ITreeNode[] children, int first, int rows) { this.dataModel = dataModel; this.children = children; this.first = first; this.rows = rows; // Move to the first entry dataModel.setRowIndex(first); if(dataModel.isRowAvailable()) { this.current = new RepeatNode(this,children[0],dataModel.getRowData(),dataModel.getRowIndex()); this.nextIdx = 1; } }
Example #10
Source File: JdbcDynamicColumnBuilderFactory.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public DynamicColumnBuilder createColumnBuilder(FacesContext context, UIDynamicViewPanel viewPanel, DataModel dataModel) { if(dataModel instanceof JdbcDataAccessorModel) { return new JdbcDynamicColumnBuilder(context,viewPanel); } return null; }
Example #11
Source File: UIPagerExpand.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected ViewNavigatorEx getNavigator() { FacesDataIterator dataIterator = findDataIterator(); if(dataIterator!=null) { DataModel dm = dataIterator.getDataModel(); if(dm instanceof DominoViewDataModel) { DominoViewDataModel ddm = (DominoViewDataModel)dm; DominoViewDataContainer dc = ddm.getDominoViewDataContainer(); if(dc!=null) { return ddm.getDominoViewDataContainer().getNavigator(); } } } return null; }
Example #12
Source File: FacesDataIteratorStateManager.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected TabularDataModel getTabularDataModel(FacesDataIterator iterator) { DataModel dm = iterator.getDataModel(); if(dm instanceof TabularDataModel) { return (TabularDataModel)dm; } return null; }
Example #13
Source File: FacesDataIteratorStateManager.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected ViewNavigatorEx getDominoViewNavigator(FacesDataIterator iterator) { DataModel dm = iterator.getDataModel(); if(dm instanceof DominoViewDataModel) { DominoViewDataModel ddm = (DominoViewDataModel)dm; DominoViewDataContainer dc = ddm.getDominoViewDataContainer(); if(dc!=null) { return dc.getNavigator(); } } return null; }
Example #14
Source File: UIDataView.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
/** * Convenience method for retrieving the <code>TabularDataModelEx</code> object * associated with this component. * @return the TabularDataModel */ protected TabularDataModel getTabularDataModel() { DataModel dataModel = getDataModel(); if (dataModel instanceof TabularDataModel) { return (TabularDataModel) dataModel; } return null; }
Example #15
Source File: DominoDynamicColumnBuilder.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected View findView() { DataModel dm = panel.getDataModel(); if(dm instanceof DominoViewDataModel) { return ((DominoViewDataModel)dm).getView(); } return null; }
Example #16
Source File: DominoDynamicColumnBuilderFactory.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public DynamicColumnBuilder createColumnBuilder(FacesContext context, UIDynamicViewPanel viewPanel, DataModel dataModel) { if(dataModel instanceof DominoViewDataModel) { return new DominoDynamicColumnBuilder(context,viewPanel); } return null; }
Example #17
Source File: JdbcDynamicColumnBuilder.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected String findQuery() { DataModel dm = panel.getDataModel(); if(dm instanceof JdbcDataAccessorModel) { return ((JdbcDataAccessorModel)dm).getQuery(); } return null; }
Example #18
Source File: DataSourceIteratorRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected int calculateIndentOffset(FacesContext context, UIDataSourceIterator c, ViewDefinition viewDef) { // Else get it from the data model DataModel dm = viewDef.dataModel; if(dm instanceof TabularDataModel) { TabularDataModel tbm = (TabularDataModel)dm; return tbm.getColumnIndentLevel(); } return 0; }
Example #19
Source File: DataSourceIteratorRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected int getColumnIndentLevel(FacesContext context, UIDataSourceIterator c, ViewDefinition viewDef) { // If the view is forced as flat... if(viewDef.showItemsFlat) { return 0; } // Else get it from the data model DataModel dm = viewDef.dataModel; if(dm instanceof TabularDataModel) { TabularDataModel tbm = (TabularDataModel)dm; return tbm.getColumnIndentLevel()-viewDef.indentOffset; } return 0; }
Example #20
Source File: DataSourceIteratorRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected boolean isRowLeaf(FacesContext context, UIDataSourceIterator c, ViewDefinition viewDef) { DataModel dm = viewDef.dataModel; if(dm instanceof TabularDataModel) { TabularDataModel tbm = (TabularDataModel)dm; return tbm.isRowLeaf(); } return true; }
Example #21
Source File: DataSourceIteratorRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected String getRowPosition(FacesContext context, UIDataSourceIterator c, ViewDefinition viewDef) { DataModel dm = viewDef.dataModel; if(dm instanceof TabularDataModel) { TabularDataModel tbm = (TabularDataModel)dm; return tbm.getRowPosition(); } return null; }
Example #22
Source File: DataSourceIteratorRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected boolean isRowExpanded(FacesContext context, UIDataSourceIterator c, ViewDefinition viewDef) { DataModel dm = viewDef.dataModel; if(dm instanceof TabularDataModel) { TabularDataModel tbm = (TabularDataModel)dm; return tbm.isRowExpanded(); } return false; }
Example #23
Source File: DataSourceIteratorRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected boolean isTotalRow(FacesContext context, UIDataSourceIterator c, ViewDefinition viewDef) { DataModel dm = viewDef.dataModel; if(dm instanceof TabularDataModel) { TabularDataModel tbm = (TabularDataModel)dm; return tbm.isRowTotal(); } return false; }
Example #24
Source File: DataSourceIteratorRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected boolean isCategoryRow(FacesContext context, UIDataSourceIterator c, ViewDefinition viewDef) { DataModel dm = viewDef.dataModel; if(dm instanceof TabularDataModel) { TabularDataModel tbm = (TabularDataModel)dm; return tbm.isRowCategory(); } return false; }
Example #25
Source File: DataViewRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected int getIndentLevel(ViewDefinition viewDef) throws IOException { // assumes that the caller int level = 0; TabularDataModel tdm; DataModel dm = viewDef.dataModel; if(dm instanceof TabularDataModel) { tdm = (TabularDataModel)dm; level = tdm.getColumnIndentLevel(); } return level; }
Example #26
Source File: TabRepeat.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
private void setIndex(FacesContext ctx, int index) { DataModel localModel = getDataModel(); if (index == -1 && initialChildState == null) { saveInitialChildState(ctx); } // save child state if (this.index != -1 && localModel.isRowAvailable()) { this.saveChildState(ctx); } else if (this.index >= 0 && this.childState != null) { this.removeChildState(ctx); } this.index = index; localModel.setRowIndex(index); if (this.index != -1 && this.var != null && localModel.isRowAvailable()) { Map<String, Object> attrs = ctx.getExternalContext().getRequestMap(); attrs.put(var, localModel.getRowData()); } // restore child state if (this.index != -1 && localModel.isRowAvailable()) { this.restoreChildState(ctx); } }
Example #27
Source File: QuestionPoolDataModel.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Creates a new QuestionPoolDatModel object. */ public QuestionPoolDataModel(Tree tree, DataModel model) { this.model = model; this.tree=tree; //buildTree(); }
Example #28
Source File: MovieController.java From tomee with Apache License 2.0 | 4 votes |
public DataModel getItems() { if (items == null) { items = getPagination().createPageDataModel(); } return items; }
Example #29
Source File: SerializationStructureCompare.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
public static String compareWithFailsResult(SerializationCompareContext context, String message, String methodName, Object object1, Object object2) { // System.out.println("SerializationStructureCompare.compareWithFailsResult() checking "+message); if( null == object1 || null == object2 || context.nonRecursiveComparators.isHasComparator(object1.getClass()) ){ return context.nonRecursiveComparators.applyComparator(context, message, methodName, object1, object2); } if (object1 instanceof UIComponent){ if(context.isSkipMethod(object1.getClass(), methodName)){ return ""; // pass } if( !"getChildren".equals(methodName) && !"getFacets".equals(methodName) ){ return message+" get method should not return a UIComponent\n"; } UIComponent comp1 = (UIComponent)object1; UIComponent comp2 = (UIComponent)object2; return new SerializationFullComparator(context).compareWithFailsResult(comp1, comp2); }else if( object1 instanceof StateHolder ){ // most complex-types are StateHolders, and will be reflection compared context.pushMessage(message +"(" +XspTestUtil.getShortClass(object1)+")"); try{ return new SerializationFullComparator(context).compareWithFailsResult(object1, object2); }finally{ context.popMessage(); } }else if (object1 instanceof Map) { return compareMaps(context, message, methodName, (Map<?,?>)object1, (Map<?,?>)object2); } else if (object1 instanceof List) { return compareLists(context, message, methodName, (List<?>)object1, (List<?>)object2); } else if (object1 instanceof Iterator) { return compareIterators(context, message, methodName, (Iterator<?>)object1, (Iterator<?>)object2); } else if (object1 instanceof Object[]) { return compareObjectArrays(context, message, methodName, (Object[])object1, (Object[])object2); } else if (object1 instanceof MethodBinding) { return compareMethodBindings(context, message, methodName, object1, object2); } else if (object1 instanceof ValueBinding) { return compareValueBindings(context, message, methodName, object1, object2); } else if (object1 instanceof DataModel) { return compareDataModels(context, message, methodName, object1, object2); } else if ("com.ibm.jscript.types.FBSGlobalObject".equals(object1 .getClass().getName())) { // not comparing FBSGlobalObject instances, // as they are directly generated from the Server script libraries // so if the scripts are the same these objects will be the same. } else{ // Package package1 = object1.getClass().getPackage(); // if( null != package1 && package1.getName().startsWith("xsp.") ){ // // not compare the test beans. // return; // } System.out.println(message + " (Unhandled Class) -> " + object1.getClass().getName()); } return ""; }
Example #30
Source File: JdbcDataSource.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
@Override public DataModel getDataModel() { return new JdbcDataAccessorModel(this,(Container)getDataContainer()); }