Oracle WebCenter 11g provides out of the box ADF task flows for Oracle UCM 11g content repository management - Oracle Universal Content Management 11g and Oracle ADF/WebCenter 11g Integration. It might be not enough, especially when implementing custom solutions. For those custom cases, we have option to define Data Control connection and retrieve information about stored documents through Bindings layer. One practical use case - select and retrieve ID's for the selected documents, store those ID's into database table. I will describe in this blog, how to retrieve selected documents ID's from Data Control defined on Content Repository connection.
Sample application allows user to select documents from custom list-of-values screen and retrieves ID's of these documents for future processing - UCMNewFolderDC.zip.
Oracle WebCenter 11g ADF task flow for Content Repository provides all required functionality:
However if we want to implement custom screens, for example like this custom list-of-values with documents for selected employee, we need to use Data Control generated for Content Repository connection:
Users will be able to select multiple documents and store their selection into database (custom functionality):
ID's and names for the selected documents are retrieved and can be processed in ADF:
Data Control for Content Management connection is created directly from Content Repository connection:
By default, document ID is not included into Data Control attributes list. You should add one more attribute, name it id (or give any other name you like) and change type to Long:
JCR Path points to Oracle UCM 11g Content Repository metadata structure. You will retrieve document ID, by pointing to jcr:content/idc:metadata/idc:dID. This will bring ID for current document:
Standard ADF Data Control is generated, there is getItems(path, type) method to retrieve list of documents from Content Repository by predefined path and type (all, documents or folders):
Drag and drop Return variable of getItems(path, type) method into ADF Faces fragment/page and create ADF Faces table component (filtering, sorting and selection features are provided by default):
Name column is combined to show document name:
And same time to open content by document URI:
Oracle UCM 11g Data Control method getItems(path, type) provides two parameters - path and type. Sample application retrieves folder path dynamically and brings only documents (no folders):
Custom list-of-values dialog listener is retrieving keys of the selected rows and accessing id/name values for each selected document:
There is one trick, when you want to enable multiple selection and access selected row keys in Java. First, make sure multiple selection property is set:
Then make sure, this line is removed from ADF Faces table tag:
selectionState= "#{bindings.findAllDepartments1.collectionModel.selectedRow}"
Otherwise, it will return always only one selected key. Based on my blog post from 2007 for ADF 10g, seems like some things never change - Multi-selection feature and ADF Faces af:table component.
HI Andrejus,
ReplyDeleteI was unable to deploy this sample in jdeveloper 11.1.2.0.0. I an getting the following error:
Error: An unreported error occurred in Appc. No errors were reported, but the tool returned a failure result code: 1.
Of course, I would be surprised if it would work for you. JDev 11.1.2.0.0 doesnt have WebCenter extension and you need to have it to run this sample :)
ReplyDeleteAndrejus
You blog entry had a number of details in it that were very helpful...thank you for posting this for those of us new this ADF/UCM development.
ReplyDeleteAfter getting this working I loaded my UCM test server with about 2500 documents which uncovered a problem with the data control I can not solve - No matter what I change, the data control returns 200 records - no more. I have changed RangeSize and RowCountThreshhold on the af:table, rowLimit property in the adf-config.xml file to 3000...nothing seems to work. Did you encounter any problem like this with your custom UI ?
After further investigation I've come to conclusion that UCM's 200 limit is either a bug or some kind of built in limitation that can not be fixed.
ReplyDeleteI'm reworking my user interface to use a different data control and preliminary testing suggest it works as it should....with no problems.
Yes, this can be UCM limitation. I believe it can be changed through configuration - but is not recommended. Better is to restructure UCM folders structure.
ReplyDeleteAndrejus
Hi Andrejus,
ReplyDeleteI have a WebCenter portal application, where we have a requirement to display the PDF's in UCM based on DocId. We are using DocumentViewer taskflow for the same. We are providing the value for "resourceId" as "${'UCMConnection#dDocName:pageFlowScope.VendorAcceptance.vendDocId'}". The PDF is not displayed. Also if we define UCM connection in "Application Resources" tab, and drag the drop the document viewer taskflow, how the connection details need to be updated when we move from test environment to Production environment
HI Andrejus,
ReplyDeleteI the datacontrols created in my project and everything works fine,but further I am trying to have Upload and Delete functionalities with following code:
private String path = "/",keyword = "",namePattern = "";
private boolean isRecursive = false;
private String name,title,type,description;
private UploadedFile file;
public void uploadListener(DialogEvent dialogEvent) {
if(dialogEvent.getOutcome() != DialogEvent.Outcome.no) {
try
{
File f = UCM_API.inputStreamToFile(
file.getInputStream(),file.getFilename());
UCM_API.uploadDocument(title, type, f,description);
BindingContainer bindings =
BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding operationBinding =
bindings.getOperationBinding("search");
operationBinding.execute();
operationBinding = bindings.getOperationBinding("Execute");
operationBinding.execute();
}
catch(Exception e) {
e.printStackTrace();
}
}
}
public void deleteDoc(ActionEvent e) {
String ID = (String)this.getAttributeValue("searchIterator", "dID");
String name = (String)this.getAttributeValue("searchIterator", "title");
UCM_API.deleteContent(ID, name);
BindingContainer bindings =
BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding operationBinding =
bindings.getOperationBinding("search");
operationBinding.execute();
operationBinding = bindings.getOperationBinding("Execute");
operationBinding.execute();
}
Hi,
ReplyDeleteis it possible to connect third party JCR repository to Oracle ADF without WebCenter or even better - to make use of same Connection adapter for UCM and for third party JCR repository?
Andrejus,
ReplyDeleteI was unable to deploy this sample app to the Oracle WebCenter 12c. I keep getting the weblogic.common.Resource Exception: Data Source HrDS already exists when I deploy the sample app. Any suggestion?
Nathan
Would be good to have a working sample to work with 12c ADF and 12c UCM.
ReplyDelete