只要您在 XPage 应用程序中使用它们,这是可能的。我不确定您将获得什么好处而不是直接访问视图,但这里是代码:
1.您需要一个帮助类来访问表格数据模型
/**
* Returns the tabular data model from a datasource
*
* @author Christian Guedemann, Sven Hasselbach
* @param dsCurrent
* datasource to get the tdm from
* @param context
* current FacesContext instance
* @return
* TabularDataModel
*/
public static TabularDataModel getTDM(DataSource dsCurrent, FacesContext context) {
try {
if (dsCurrent instanceof ModelDataSource) {
ModelDataSource mds = (ModelDataSource) dsCurrent;
AbstractDataSource ads = (AbstractDataSource) mds;
ads.load(context);
DataModel tdm = mds.getDataModel();
if (tdm instanceof TabularDataModel) {
TabularDataModel tds = (TabularDataModel) tdm;
return tds;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
2.你必须创建你的数据源并将它们添加到一个组件,fe view root
DominoViewData dvd = new DominoViewData();
dvd.setViewName( "YOUR VIEW NAME" );
dvd.setComponent( FacesContext.getCurrentInstance().getViewRoot() );
3.现在您可以将过滤器选项或任何其他选项添加到您的数据源,这些:
dvd.setSortOrder( "ascending" );
dvd.setSortColumn( "NAME OF COLUMN" );
4.然后访问数据源的TDM,得到第一个条目,你有一个父级的句柄,一个ViewNavigator
TabularDataModel tdm = getTDM( dvd, FacesContext.getCurrentInstance() );
tdm.setDataControl( new UIDataEx() );
Entry noiEntry = (Entry) tdm.getRowData();
ViewNavigator nav = null;
try {
nav = (ViewNavigator) noiEntry.getParent();
System.out.println( "NAV COUNT: " + nav.getCount() );
nav.recylce();
} catch (NotesException e) {
e.printStackTrace();
}
(好的,你现在有一个 ViewNavigator 而不是 ViewEntryCollection)